Jump to content

Recommended Posts

ok heres the issue. Im trying to weed out entries that dont fill in all of the info. The issue is that my if statement isnt ever evaluating to true. Can anyone explain to me why?

 

(it always runs the else block that calls the mail() function.)

 

if(isset($_POST['incoming_data']))
	{		
		if(!isset($_POST['director']) || !isset($_POST['class']) || !isset($_POST['description']))		
{
			echo "Error! All fields must be filled out!";
		}
		else
		{
			$director = $_POST['director'];
			$room = $_POST['room'];
			$class = $_POST['class'];
			$description = $_POST['description'];

			//do a mail() call			
}                             
}		

Link to comment
https://forums.phpfreaks.com/topic/141158-solved-easy-problem-im-sure/
Share on other sites

Every form value is always "set" per say. Try checking if the value is equal to nothing:

 

if(isset($_POST['incoming_data']))
      {      
         if($_POST['director']=="" || $_POST['class']=="" || $_POST['description']=="")      
{
            echo "Error! All fields must be filled out!";
         }
         else
         {
            $director = $_POST['director'];
            $room = $_POST['room'];
            $class = $_POST['class'];
            $description = $_POST['description'];
         
            //do a mail() call         
}                             
}      

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.