faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 63 people (37%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

PHP Newbie: HTML form calls PHP file, unable to access Html form variables in php; please help?

Dec 3rd, 2004 09:39
Andrew Figula, Mark Wright, B Harris,


Whenever you submit a form to a a php script then the values submitted 
by that form are available to you as variables with then name of the 
variables being the name of the form fields.

For example if you have a form that has two fields - one called name 
and the other email then the php script will be able to access a 
variable called $name and one called $email. The values of these two 
fields will be the same as the user entered.

Unless you are running on php 4.1 or higher. If so, you must use 
$myvar=$_GET[$myvar]  if Get is the method of the form, 
if its not you can use $myvar=$_POST[$myvar] where $myvar is the name 
of the field in form eg."<input type=text name=myvar>. there can be 
some notice's displayed but the variables will be restored. You can 
avoid this by setting error_reporting(0) or something :)