Jump to content

How can I test the $_POST array to see if it is set by the form


Conjurer

Recommended Posts

I have a form that is populating fields based on a database query.  I am then trying to update the database based on any changes made in the form and passed through a POST action.

 

The problem I am having is with the block where I declare short variable names for the $_POST variables that will be passed when the user hits the submit button.  For each variable declaration I get an error message like this:

Encountered error: 8 in mbr_profile_updt_form.php, line 130: Undefined index: email

 

I have tried testing the $_POST variable using the isset function but it apparently is set but empty. 

 

What would be a good way to test to see if the user has pressed the submit button before I go into the processing block that is intended to handle those values from the form?

 

Here is where my code is at right now:

	if (!isset($_POST))
	{
		throw new Exception('You have not filled the form out completely - please go back'
		.' and try again.');    
	}
else
	{
	//filled in so create short variable names
		$email=$_POST['email'];
		$first_name=$_POST['first_name'];
		$last_name=$_POST['last_name'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.