|
-
Sep 27th, 2012, 03:52 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] php Many forms
Hi guys. I have a question.
If I have many form codes with same name like these:
Code:
<form action="reservedata.php" method="post">
<input type="text" name="Name" />
<input type="submit" value="reserve" name="button1" />
</form>
<form action="reservedata.php" method="post">
<input type="text" name="Name" />
<input type="submit" value="reserve" name="button2" />
</form>
<form action="reservedata.php" method="post">
<input type="text" name="Name" />
<input type="submit" value="reserve" name="button3" />
</form>
And if I click on the submit button, would the result $_POST['Name'] will change depending on the button that I click?
For example, the three textboxes have different values like "George", "Paul" and "Andrew".
If I click on the button1, would the result be "George" or if I click on the button 2 would the result be "Andrew"?
Manny Pacquiao once posted in his twitter:
It doesn't matter if the grammar is wrong, what matter is that you get the message
-
Sep 27th, 2012, 03:55 AM
#2
Thread Starter
Fanatic Member
Re: php Many forms
I have a previous thread and if the answer in my question is yes then my problem with the other thread and this will be marked as solve.
Sorry if I keep on opening many threads at the same time.
Manny Pacquiao once posted in his twitter:
It doesn't matter if the grammar is wrong, what matter is that you get the message
-
Sep 29th, 2012, 10:01 AM
#3
Re: php Many forms
If the user presses the first button, then the value in that textbox with the button will be available at the server side.
For example, if the user enter the value "a", "b", "c" in each of the textboxes and presses the first form's button, then the values available in the $_POST array would be:
PHP Code:
Array ( [Name] => a [button1] => reserve )
If it was the second button that the user pressed, then the values would be:
PHP Code:
Array ( [Name] => b [button2] => reserve )
And for the third:
PHP Code:
Array ( [Name] => c [button3] => reserve )
That is, when you access the "Name" element of the $_POST array like this:
PHP Code:
echo $_POST['Name'];
you will get the value from the textbox belonging to the form, which the user had pressed the button.
Hope it's clear. Let me know if you are still having trouble understanding it.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 29th, 2012, 09:51 PM
#4
Thread Starter
Fanatic Member
Re: php Many forms
I actually tried it myself and my idea really worked out. Thanks for the reply @akhileshbc
No more problems so far. I'll marked two of my threads solve and link the solution from the other thread here.
Manny Pacquiao once posted in his twitter:
It doesn't matter if the grammar is wrong, what matter is that you get the message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|