开发者

Form action takes me to basic URL

I have a form:

<form name='inputform' method='post' action='fruit.php?action=add&fruit_id=5' enctype='multipart/form-data'>

But after the submit, it just takes me to fruit.php without the extra details (&action=a开发者_开发百科dd&fruit_id=5)

I assume this is how the action-thingy works, but is it possible be taken to the actual URL stated?

I hope I've described it thoroughly enough for you to understand what I want.


Unfortunately this is a cross browser issue. Some browsers remove the query string at the end. Your best bet is to add those variables action and fruit_id in as input type=hidden

<form method="post" action="fruit.php">
    <input name="action" type="hidden" value="add">
    <input name="fruit_id" type="hidden" value="5">
</form>

Don't forget to consider that fruit.php should be reading $_POST and not $_GET for the fruit id and action.


There is a syntax error in your action string. The URL is malformed.

It should be

<form name='inputform' method='post' action='fruit.php?action=add&fruit_id=5' enctype='multipart/form-data'>


The values you have in the query string (action=add and fruit_id=5) can be replaced by putting hidden input fields on your form.

I am a little surprised that it strips the query string off of the action. I've never tried it before, but it could just be standard browser behavior.

HTH


The better way is to put those parameters as Hidden values in your form and as your form is submitted as POST :

<form name="inputform" method="post" action="fruit.php" enctype='multipart/form-data'>
    <input name="action" type="hidden" value="add" />
    <input name="fruit_id" type="hidden" value="5" />
</form>

Note that the enctype='multipart/form-data' will only be usable if you upload a file to your server.


Check the code that your action button uses (i.e. did you accidentally paste unwanted javascript into that button?).

One simple test to see if your button action is interfering with the form's action is to press enter inside of a text box in your form, which may ignore whatever script your button uses to submit the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜