how do i make all these fields required in my form?

the first 2 fields are required, but when i tried to copy the way it was scripted for the rest of the fields it comes back with an error … please help me make all the fields required


[php]<?php
$to = $_REQUEST[‘sendto’] ;
$from = $_REQUEST[‘Email’] ;
$name = $_REQUEST[‘Name’] ;
$headers = “From: $from”;
$subject = “Web Contact Data”;

$fields = array();
$fields{“Name”} = “Name”;
$fields{“Lastname”} = “Lastname”;
$fields{“ContactNumber”} = “ContactNumber”;
$fields{“Email”} = “Email”;
$fields{“Message”} = “Message”;

$body = “We have received the following information:\n\n”; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = “From: [email protected]”;
$subject2 = “Thank you for contacting us”;
$autoreply = “Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at www.keystonecoaching.co.za”;

if($from == ‘’) {print “You have not entered an email, please go back and try again”;}
else {
if($name == ‘’) {print “You have not entered a name, please go back and try again”;}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( “Location: http://www.keystonecoaching.co.za/test/confirm.htm” );}
else
{print “We encountered an error sending your mail, please notify [email protected]”; }
}
}
?> [/php]

this can help…

[php]

<?php $to = $_REQUEST['sendto'] ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = "Web Contact Data"; $fields = array(); $fields{"Name"} = "Name"; $fields{"Lastname"} = "Lastname"; $fields{"ContactNumber"} = "ContactNumber"; $fields{"Email"} = "Email"; $fields{"Message"} = "Message"; $flag = true; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); if($_REQUEST[$a]=='') $flag = false; } $headers2 = "From: [email protected]"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at www.keystonecoaching.co.za"; if($from == '') { print "You have not entered an email, please go back and try again"; } else if($name == '') { print "You have not entered a name, please go back and try again"; } else if ($flag == false) { print "All fields are required. Please check."; } else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.keystonecoaching.co.za/test/confirm.htm" );} else {print "We encountered an error sending your mail, please notify [email protected]"; } } ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service