| | |
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 |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link links login mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion regex remote script search searchbox server session sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web website window.onbeforeunload=closeme; xml youtube






