| | |
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 |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube






