404 on form submission
I keep getting 404 error when I try to submit this form. In my site directory, I have a named folder mobile
that has forms.php
and inside it process.php
.
The form is on this page
http://localhost/mobile/forms.php?ft=0&id=2
here is the form
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
//details
</form>
When I try to submit, I get a 404 error, when should it go to http://localhost/mobile/process.php?o=9&ft=0
? How to fix it?
source to share
By looking at the url, I conclude that both php files are on the same page, so change the url of the action from
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
For
<form action='process.php?o=9&ft=0' method='POST'>
The forward slash before mobile
means that it selects the folder from the root. So you probably don't need this here.
Last but not least, make sure the filenames are correct, and also make sure the cases are the same because the filenames are case sensitive.
Note. You can also get a 404 error if you use
header('Location: xyz.php');
on the form processing page to redirect the user to some pages after the form process, and you may run into404
because the page the script is redirected to does not exist. so make sure the url is correct if you useheader()
source to share