note 27404 added to tutorial.forms

From: Date: Wed, 04 Dec 2002 20:47:13 +0000
Subject: note 27404 added to tutorial.forms
Groups: php.notes 
Request: Send a blank email to php-notes+get-40349@lists.php.net to get a copy of this message
when using the post method for a form, you have the ability to call the variables directly by name without using $_REQUEST,$_POST,$_GET on the variable. If you enclose the entire webpage in one big <?php tag and call the page itself, you can just call a variable by its name and get the sent value. Example: Enitre php page enclosed in one php tag! <? echo " <HTML> <body> <form action=\"?\" method=\"POST\"> Your name: <input type=\"text\" name=\"name\"> Your age: <input type=\"text\" name=\"age\"> <input type=\"submit\" value=\"Submit\" name=\"sent\"> </form> "; if (!isset($sent)){ echo "Name and Age not set!"; } else{ echo "Name $name and Age $age"; } echo "</body></html>"; ?> For functions within the code, you'd have to pass the variable. This is only for simple code. -- http://www.php.net/manual/en/tutorial.forms.php http://master.php.net/manage/user-notes.php?action=edit+27404 http://master.php.net/manage/user-notes.php?action=delete+27404 http://master.php.net/manage/user-notes.php?action=reject+27404

« previous php.notes (#40349) next »