I keep getting a 404 error when trying to submit this form. In my website directory i have a folder called mobile, which inside has forms.php and process.php.
The form is located 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 it should go to http://localhost/mobile/process.php?o=9&ft=0? How do i fix this?
By looking at the URL's what I conclude is that both the php files are on the same page so change your action url from
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
To
<form action='process.php?o=9&ft=0' method='POST'>
A forward slash before the mobile means it selects the folder from the root.. So you probably don't need that here.
Last but not the least, be sure the file names are proper, and also make sure the cases are same, because the file names are case sensitive.
Note: You may also get 404 error if you are using header('Location:
xyz.php'); on the form processing page, for redirecting the user to
some page after the form processes and you may encounter 404 because
the page on which the script has redirected doesn't exist. so make sure
that the URL is correct if you are using header()
Try changing
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
to
<form action='process.php?o=9&ft=0' method='POST'>
Since they are in the same directory.
You can't pass a GET parameter in the form action.
In order to pass parameters, you will have to create a hidden input like :
<input type="hidden" name="o">
Related
I've got an annoying problem.
My website https://exmple.com has a contact form.
The logic is placed in the same directory as the send.php file.
In general, an email form works, however, sometimes I get "Server not found" error (1/10). What may be to resign for this weird behaviour?
The form looks like:
<form method="post" action="send.php">
...
</form>
I've already tried:
action = "send.php"
action = "/send.php"
action = "https://exmple.com/send.php"
Each try gives the same result.
This is a SSL connection, index.php file is in the same directory as send.php.
Thanks for your help!
I have a problem where, when submitting my form, it seems to ignore my routing and redirects me to the Home instead.
In my main.php routing:
'<language\w+>/profile/<slug:[\w\-]+>' => 'profile/index',
'<language\w+>/<action:\w+>' => 'site/index',
My form:
<form action="<?php echo Yii::app()->getBaseUrl()."/".Yii::app()->language;?>
/profile/calendar" method="post">
Which outputs to
<form action="/domainname/nl/profile/calendar" method="post">
Note: domainname is there because I'm testing this on localhost.
However, when pressing the submit button it forwards me to the home instead of the correct page. Simply visiting /domainname/nl/profile/calendar in the browser does work and gives me the correct controller. I don't know why it isn't working in the form.
In a different form on the same website, I have the following, which again does work fine for the routing:
<form action="/domainname/nl/profile/info" method="post">
The difference between these 2 forms is that the last one is created through CActiveForm widget and the first one isn't.
Make simple post request to "/domainname/nl/profile/info" and watch for response headers. Or you can analyze existing requests with tcpdump or something simular
I managed to work around the issue by switching my manual form to use the CActiveForm widget after all. It seems I needed the yii_cs_csrf_token that is automatically generated by CActiveForm.
Let's say I have a form on my website homepage: www.mysite.com
Now, the form tag looks like this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
...
</form>
When that form submits, it does everything it's suppose to. But it also reloads the page with the full filename and extension. So the user will now find the URL in the address bar is: www.mysite/index.php
Is there a way to make the form fire to the same page without adding this extension?
There may be situations where the form is as an include in a footer, so I cann't be specific about the page the form needs to fire to, hense the PHP_SELF code.
That's because $_SERVER['PHP_SELF'] refers to the actual filename of the current script.
Try this:
<form action="" method="post">
An empty action will post back to the current URL.
Try setting the action to #:
<form action="#" method="post">
...
</form>
The # refers to the current page.
Try changing action to #, this post to the current page.
Edit: Mike beat me to it.
Edit 2: It looks like you can leave out the action all together and it will default to the same page.
Edit 3: Mike beat me to that one too.
I have build a form in which you can add images. Unfortunatelly, I am not able to call "move_uploaded_file" in PHP, as the server is running PHP safe mode and there is no way to modify this (I have checked). Therefore, I submit my form to my OWN server, which handles the file uploading.
On my own server, the file however; is not found. I think it has to do with the form calling the external url.
I know this because
echo $_FILES['uploadFile']['name'] ."<br>";
returns just an empty line.
The form itself is:
<form action="http://ejw.patrickh.nl/load.php" method="get" enctype="multipart/form-data" onsubmit ="return checkInput();"> </form>
and contains several input buttons.
Bottomline: the form on my own server submits the file perfectly, however when I make use of the form which is on another site, with the above action; no file is found.
Can this be fixed, and if so; how?
Thanks in advance!
You have to use method="post" to submit files.
Also the enctype attribute alone can be used only, if method="post".
I have this simple html form :
<form action="../../process.php" method="POST">
----SOME INPUT HERE----
<input type="submit" value="Submit">
</form>
and that form located under this folder : /public_html/userweb/subdomain.domain.com/form.php while the process.php is located under /public_html folder.
the problem is... /public_html/userweb/subdomain.domain.com is actually a sub-domain's root folder and /public_html is the TLD's root folder.
my question is can a HTML form submission in sub-domain process by TLD? if so, how to do it? because that form always search process.php under subdomain.domain.com/process.php not domain.com/process.php
A form action can be any url. For example, this form submits a search query to google:
<form action="http://www.google.com/">
<p><input name="q"></p>
</form>
To do what you describe, just use a full url as your action, such as //domain.com/process.php
The action of the form could be any URL, but not the path in the server.
You just need to set the action like:
<form action ="//domain.com/process.php" method="post">
AJAX it to the domain you want to send it to, and send it as jsonp.
Edit: I was thinking of the Same Origin Policy, where you are restricted in what datatypes you can transmit cross-domain.