View Full Version : Need help with returning fields from form

05-27-2011, 10: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">
<label for="name">Full Name <span class="red">(required)</span></label>
<input id="name" name="name" class="text" />
<label for="email">Your email <span class="red">(required)</span></label>
<input id="email" name="email" class="text" />
<label for="coupon">Coupon Name <span class="red">(required)</span></label>
<input id="coupon" name="coupon" class="text" />
<label for="dog">Dog Name <span class="red">(required)</span></label>
<input id="dog" name="dog" class="text" />

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


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";
if($errors==1) echo $error;
$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( 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!';


05-27-2011, 11:04 PM
plz help :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum