| | |
PHP $POST and Input Order
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hello,
I have a question about PHP. I realized that you can use the POST variable to get data from a form submitted with the type post, but does the order of the fields matter. Example:
index.html:
Here's the code for submit.php:
My question is: Why does flipping the two POST vars make this code not work? If there is a way (besides of course writing it as the values are ordered, which will be hard since I am not sure what order the form's elements will be in) to get by this? Thanks Everyone for your great help!!!
I have a question about PHP. I realized that you can use the POST variable to get data from a form submitted with the type post, but does the order of the fields matter. Example:
index.html:
HTML Syntax (Toggle Plain Text)
<HTML> <HEAD> <TITLE>Form</TITLE> </HEAD> <BODY> <FORM name='test' action='submit.php' method='post'> Name: <INPUT type='text' name='name' /><br /> Programming Language <INPUT type='text' name='lang' /><br /> <INPUT type='submit' value='submit' /> </FORM> </BODY> </HTML>
PHP Syntax (Toggle Plain Text)
<?php //This code works echo $_POST['name']; echo "<br />" echo $_POST['lang']; //But if I flip the two, it doesn't. echo $_POST['lang']; echo "<br />" echo $_POST['name']; ?>
Last edited by FlashCreations; Oct 17th, 2008 at 11:56 pm.
•
•
Join Date: Oct 2008
Posts: 1
Reputation:
Solved Threads: 1
•
•
•
•
Hello,
I have a question about PHP. I realized that you can use the POST variable to get data from a form submitted with the type post, but does the order of the fields matter. Example:
index.html:
Here's the code for submit.php:HTML Syntax (Toggle Plain Text)
<HTML> <HEAD> <TITLE>Form</TITLE> </HEAD> <BODY> <FORM name='test' action='submit.php' method='post'> Name: <INPUT type='text' name='name' /><br /> Programming Language <INPUT type='text' name='lang' /><br /> <INPUT type='submit' value='submit' /> </FORM> </BODY> </HTML>
My question is: Why does flipping the two POST vars make this code not work? If there is a way (besides of course writing it as the values are ordered, which will be hard since I am not sure what order the form's elements will be in) to get by this? Thanks Everyone for your great help!!!PHP Syntax (Toggle Plain Text)
<?php //This code works echo $_POST['name']; echo "<br />" echo $_POST['lang']; //But if I flip the two, it doesn't. echo $_POST['lang']; echo "<br />" echo $_POST['name']; ?>
yes, in POST variable are stored in a array called $_POST...so we can retrieve them with key like $_POST['lang']; or $_POST['name']; or some thing...No matter of order...
or As adilkhan said,try to print print_r($_POST);...
or As adilkhan said,try to print print_r($_POST);...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
![]() |
Similar Threads
- Need Help To Complete Php Project!! (PHP)
- PHP how to send results from one query to another php script (PHP)
- Hidden variable in php (PHP)
- php mysql question (PHP)
- php script (PHP)
- vBulletin mod_rewrite for vB 3.0.7 (Existing Scripts)
- Zend PHP Certification (PHP)
- Can't see mysql records using php in any browser (PHP)
Other Threads in the PHP Forum
- Previous Thread: Installing PHP on Windows XP Pro with IIS
- Next Thread: wamp server problem plz help
| Thread Tools | Search this Thread |
301 ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dynamic echo email error execution file files folder foreach form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla library limit link links login loop mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem query radio random recursion regex remote script search searchbox server session sessions sms soap sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website xml youtube zend






