Click to See Complete Forum and Search --> : 1 form three buttons help please


Creator-X
11-04-2004, 04:51 AM
Hello Guys I need some help again. Im quite new to PHP but im Ok with JAVA JSP stuff
so back to the problem i have one form with three submit buttons in form

<form name="frmOne" method="post" action="process.php">

<input name="txtName" type="text" id="txtName" size="65" maxlength="65" />


<input name="Post" type="submit" value='First' />
<input name="Post" type="hidden" value='First' />

<input name="Post" type="submit" value='Second' />
<input name="Post" type="hidden" value='Second' />

<input name="Post" type="submit" value='Third' />
<input name="Post" type="hidden" value='Third' />

</form>

This above is the example now all works fine except one thing

when i use : <?PHP print $_POST['Post']; ?> To see which button was clicked regardless which one i click the value "Third" is always displayed or it always displays the value of last button not the one that was clicked.

How to work this out does anybody know Thanks in advance

chrisranjana
11-04-2004, 05:37 AM
try

<input name="Post" type="submit" value='First' />
<input name="Post" type="submit" value='Second' />
<input name="Post" type="submit" value='Third' />

Creator-X
11-04-2004, 05:47 AM
I did try this but it does not work same effect last one is used always. :confused:
Any other sugestions please most welcome.

Creator-X
11-04-2004, 05:49 AM
Look lets say in this forum you have two options when you type this message first is post message second is preview message

How did they solve this problem

chrisranjana
11-04-2004, 06:06 AM
Well you could

<input name="Post1" type="submit" value='First' />
<input name="Post2" type="submit" value='Second' />
<input name="Post3" type="submit" value='Third' />

name all 3 buttons differently and check which button has been clicked

Creator-X
11-05-2004, 03:23 AM
Thanks for your reply but again it does not work if you do that and then you do something like

print $_POST['Post1'];
print $_POST['Post2'];
print $_POST['Post3'];

You will expect that only one will be printed the one that you click on but no all three will display values so no good.

Anyway i found solution instead of having three options i will use sesions and one button so when the user does click on this button i can store info that i require in sesion and then in the next page i can have multiple choice since i can have multiple forms with each form having one button. I looked trough my project in JSP and i found that i had same problem and the solution that i typed just now works . Anyway thanks to all replies.
Yours PHP Newbie. :)