Jump to content

[SOLVED] Easy problem im sure...


Btown2

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         
}                             
}      

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.