HELP!!! Defining variables with form values

How would i go about correctly defining the following variables that i am taking in from a form.

[php]$forrm = "

(*required)
(*required)
(*required)
";

if (isset($_POST[‘registerbutton’]))
{
$user = $_POST[‘user’];
$email = $_POST[‘email’];
$password = $_POST[‘pass’];

if ($user == "Username")
	$user = "";
if ($email == "Email")
		$email = "";[/php]

Ive tried to apply the (isset ()) function for example :(isset($_POST=‘user’)
but it doesnt seem to be defining my new variable. could anyone possible lend me some advise.

You already have answer to your question in your code:
[php]if (isset($_POST[‘registerbutton’]))[/php]

same with other variables:
[php]if(isset($_POST[‘user’]))[/php]

Basically if variable came from HTML form via post method, you can check if it is defined: isset($_POST[‘user’]).
If it is not defined, but you need this array element in your code, you can define it:
[php]$_POST[‘user’] = ‘’;[/php]

Dear Rose when you submit a form you are in effect passing over the all the ‘name’ attributes into the global variable called $_POST[’’] which is really an array that takes all the name attributes in the form. So to check if the form has been submitted, use the name attribute of the submit input that is:

if(isset ($_POST[‘registrationbutton’])){\Do whatever…
}

If you want to check whether the other variables of the other input elements have been succesfully postedjust do the same thing this time with the name attributes of the input element in question. Hope this helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service