Please help...can't get this form to work properly...

the mail() function

Moderators: macek, egami, gesf

Post Reply
FollowTheTortoise
New php-forum User
New php-forum User
Posts: 82
Joined: Sun Dec 04, 2011 1:35 pm
Location: Southern California
Contact:

Re: Please help...can't get this form to work properly...

Post by FollowTheTortoise » Thu Dec 08, 2011 7:04 am

Your misusing the if statements. It should be:

Code: Select all

if(!isset($_POST['sender_name']) || 
!isset($_POST['Full_Name']) || 
!isset($_POST['Email_Address']) ||
!isset($_POST['Telephone_Number']) ||
!isset($_POST['Your_Message']))  
NOT

Code: Select all

if(!isset($_POST['sender_name']) ||
if(!isset($_POST['Full_Name']) ||
!isset($_POST['Email_Address']) ||

!isset($_POST['Telephone_Number']) ||
!isset($_POST['Your_Message'])) 

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Please help...can't get this form to work properly...

Post by egami » Thu Dec 08, 2011 12:53 pm

Another way to do it would be:

Code: Select all


$array = array(
    'Sender Name' => 'sender_name',
    'Full Name' => 'Full_Name',
    'Email Address' => 'Email_Address',
    'Telephone Number' => 'Telephone_Number',
    'Your Message' => 'Your_Message'
  );

foreach($array as $k => $v) { 
  if (!isset($_POST[$v]) || empty($_POST[$v]) || $_POST[$v] == '' ) { 
    $error[$v] = "$k is not set. Please try again.";
  }
}

if (!isset($error)) { 
  do your thang here..
} else { 
  foreach($error as $k => $v) { 
    echo "$v<br>";
  }
}
 

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest