...

View Full Version : Need help with returning fields from form



steiger16
05-27-2011, 09:37 PM
Hi, My form currently submits to email but it is not returning the dog name and the coupon name. Code below. live example at www.localadsaver.com/contest.php



<form action="contestmailer.php" method="post" id="contactform">
<ol>
<li>
<label for="name">Full Name <span class="red">(required)</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">(required)</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="coupon">Coupon Name <span class="red">(required)</span></label>
<input id="coupon" name="coupon" class="text" />
</li>
<li>
<label for="dog">Dog Name <span class="red">(required)</span></label>
<input id="dog" name="dog" class="text" />
</li>

<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />





<?php

if(!$_POST) exit;

$email = $_POST['email'];
$name = $_POST['name'];
$coupon = $_POST['coupon'];
$dog = $_POST['dog'];


//$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 ('name','email','coupon','dog');
$required = array('name','email','coupon','dog');

$your_email = "advertise@localadsaver.com";
$email_subject = "June Contest Entry: ";
$email_content = "Contest Entry:\n Name:$name\n Email:$email\n Coupon Name:$coupon\n Dog Name:$dog\n";

foreach($values as $key => $value){
if(in_array($value,$required)){

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)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}

?>

steiger16
05-27-2011, 10:04 PM
plz help :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum