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'];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.