Hello! My form won’t show the values unless I add them to the required = array and not everything is required. So the firname, lasname, and email will show in the email that’s sent but it won’t show the phone and message (I have other fields to add too).
I don’t know PHP at all. Please help I need this fixed asap!
Here is my code:
[php]<?php
if(!$_POST) exit;
$email = $_POST[‘email’];
//$error[] = preg_match(’/\b[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b/i’, $POST[‘email’]) ? ‘’ : ‘INVALID EMAIL ADDRESS’;
if(!eregi("^[a-z0-9]+([\.-][a-z0-9]+)" ."@"."([a-z0-9]+([.-][a-z0-9]+))+"."\.[a-z]{2,}"."$",$email )){
$error.=“Invalid email address entered”;
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array(‘firname’,‘lasname’,‘email’,‘phone’,‘message’);
$required = array(‘firname’,‘lasname’,‘email’,);
$your_email = "[email protected]";
$email_subject = "Reservations Form: ".$_POST['subject'];
$email_content = "new reservation:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != '') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
header('Location: http://www.example.com/test/reservation-submission.html');
} else {
echo 'ERROR!';
}
}
?>
[/php]
Here is my html form:
[code]
- First Name *
- Last Name *
- Email *
- Phone Number *
- Best Time To Call
Morning
Afternoon
Evening
- Age
25+
21-24
- Rental *
12 Passenger Van
15 Passenger Van
Cargo Van
- Pick up Location *
Select Location
U-Save JFK
U-Save LGA
- Estimated Mileage
Under 100
100-500
500+
- Pick Up Date *
- Pick Up Time *
12:00 am 12:30 am
01:00 am 01:30 am
02:00 am 02:30 am
03:00 am 03:30 am
04:00 am 04:30 am
05:00 am 05:30 am
06:00 am 06:30 am
07:00 am 07:30 am
08:00 am 08:30 am
09:00 am 09:30 am
10:00 am 10:30 am
11:00 am 11:30 am
12:00 pm 12:30 pm
01:00 pm 01:30 pm
02:00 pm 02:30 pm
03:00 pm 03:30 pm
04:00 pm 04:30 pm
05:00 pm 05:30 pm
06:00 pm 06:30 pm
07:00 pm 07:30 pm
08:00 pm 08:30 pm
09:00 pm 09:30 pm
10:00 pm 10:30 pm
11:00 pm 11:30 pm
- Drop Off Date *
- Drop Off Time *
12:00 am 12:30 am
01:00 am 01:30 am
02:00 am 02:30 am
03:00 am 03:30 am
04:00 am 04:30 am
05:00 am 05:30 am
06:00 am 06:30 am
07:00 am 07:30 am
08:00 am 08:30 am
09:00 am 09:30 am
10:00 am 10:30 am
11:00 am 11:30 am
12:00 pm 12:30 pm
01:00 pm 01:30 pm
02:00 pm 02:30 pm
03:00 pm 03:30 pm
04:00 pm 04:30 pm
05:00 pm 05:30 pm
06:00 pm 06:30 pm
07:00 pm 07:30 pm
08:00 pm 08:30 pm
09:00 pm 09:30 pm
10:00 pm 10:30 pm
11:00 pm 11:30 pm
<li><label>Additional Infomation</label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="button1">
<input type="image" name="imageField" id="imageField" src="images/reserve-now-btn.png" class="send" />
<div class="clr"></div>
</li>
</ol>
</form>[/code]
I’d appreciate any help. Thanks!