Hi all.
I have created a php form. I have done everything right and the email sends etc which is great but i get back blank fields.
Full name:
Email:
none@noone.com
Telephone:
Comments:
nonononee none none none
Company Name:
Which Plan:
Which Phone:
When should we call you?:
Type of business:
Number of employees:
Existing number of lines:
Existing number of extensions:
Referrer contact name:
Referral email:
Referral telephone:
Referral company name:
It sends some of the info but not all. here is the code below.
<div id="contact-wrapper">
<?php if(isset($hasError)) { //If errors are found ?>
<p class="error">Please check if you've filled all the fields with valid information. Thank you.</p>
<?php } ?>
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<p><strong>Email Successfully Sent!</strong></p>
<p>Thank you <strong><?php echo $name;?></strong> for using my contact form! Your email was successfully sent and I will be in touch with you soon.</p>
<?php } ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
<div class="section_title">
<h3>Let's get started... </h3>
<p></p>
</div>
<div>
<label for="name"><strong>Full Name:</strong></label>
<input type="text" size="50" name="contactname" id="contactname" value="" class="required" />
</div>
<div>
<label for="company name"><strong>Company Name:</strong></label>
<input type="text" size="50" name="companyname" id="companyname" value="" class="required" />
</div>
<div>
<label for="email"><strong>Email:</strong></label>
<input type="text" size="20" name="email" id="email" value="" class="required email" />
</div>
<div>
<label for="telephone"><strong>Telephone:</strong></label>
<input type="text" size="25" name="telephone" id="telephone" value="" class="required" />
</div>
<div>
<label for="whentocall"><strong>When should we call you?:</strong></label>
<input type="text" size="25" name="whentocall" id="whentocall" value="" class="required" />
</div>
<div>
<label for="whichplan"><strong>Which plan?:</strong></label>
<input type="text" size="25" name="whichplan" id="whichplan" value="" class="required" />
</div>
<div>
<label for="whichphone"><strong>Which phone?:</strong></label>
<input type="text" size="25" name="whichphone" id="whichphone" value="" class="required" />
</div>
<div>
<label for="whatbusiness"><strong>Type of business?:</strong></label>
<input type="text" size="25" name="whatbusiness" id="whatbusiness" value="" class="required" />
</div>
<div>
<label for="employees"><strong>Number of employees?:</strong></label>
<input type="text" size="25" name="employees" id="employees" value="" class="required" />
</div>
<div>
<label for="lines"><strong>Existing number of lines?:</strong></label>
<input type="text" size="25" name="lines" id="lines" value="" class="required" />
</div>
<div>
<label for="extensions"><strong>Existing number of extensions?:</strong></label>
<input type="text" size="25" name="extensions" id="extensions" value="" class="required" />
</div>
<div>
<label for="notes"><strong>Comments</strong></label>
<textarea rows="3" cols="50" name="comments" id="comments" class="required"></textarea>
</div>
<div class="section_break">
<h3>Who referred you?...</h3>
<p></p>
</div>
<div>
<label for="referral name"><strong>Full Name:</strong></label>
<input type="text" size="50" name="referralcontactname" id="referralcontactname" value="" class="required" />
</div>
<div>
<label for="referral company name"><strong>Company Name:</strong></label>
<input type="text" size="50" name="referralcompanyname" id="referralcompanyname" value="" class="required" />
</div>
<div>
<label for="referral email"><strong>Email:</strong></label>
<input type="text" size="20" name="referralemail" id="referralemail" value="" class="required email" />
</div>
<div>
<label for="referral telephone"><strong>Telephone:</strong></label>
<input type="text" size="25" name="referraltelephone" id="referraltelephone" value="" class="required" />
</div>
<input type="submit" value="Send Message" name="submit" />
</form>
and the php side;
<?php
//If the form is submitted
if(isset($_POST['submit'])) {
//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}
//Check to make sure that the companyname field is not empty
if(trim($_POST['companyname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['companyname']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['telephone']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['telephone']);
}
//Check to make sure that the whentocall field is not empty
if(trim($_POST['whentocall']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['whentocall']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['whichplan']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['whichplan']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['whichphone']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['whichphone']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['whatbusiness']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['whatbusiness']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['employees']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['employees']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['lines']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['lines']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['extensions']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['extensions']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['comments']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['comments']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//Check to make sure that the name field is not empty
if(trim($_POST['referralcontactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['referralcontactname']);
}
//Check to make sure that the companyname field is not empty
if(trim($_POST['referralcompanyname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['referralcompanyname']);
}
//Check to make sure that the telephone field is not empty
if(trim($_POST['referraltelephone']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['referraltelephone']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['referralemail']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['referralemail']))) {
$hasError = true;
} else {
$email = trim($_POST['referralemail']);
}
//Check to make sure comments were entered
if(trim($_POST['comments']) == '') {
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'ryanshawgd@gmail.com, mdunbavan@gmail.com'; //Put your own email address here
$body = "\n\nFull name: \n$contactname
\n\nEmail: \n$email
\n\nTelephone: \n$telephone
\n\nComments:\n $comments
\n\nCompany Name:\n $companyname
\n\nWhich Plan:\n $whichplan
\n\nWhich Phone:\n $whichphone
\n\nWhen should we call you?:\n $whentocall
\n\nType of business:\n $whatbusiness
\n\nNumber of employees:\n $employees
\n\nExisting number of lines:\n $lines
\n\nExisting number of extensions:\n $extensions
\n\nReferrer contact name:\n $referralcontactname
\n\nReferral email:\n $referralemail
\n\nReferral telephone:\n $referraltelephone
\n\nReferral company name:\n $referralcompanyname";
$headers = 'From: Digivox Referrals/Tester email <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?>
Iam wondering if it is the email address or something. I cannot see where the problem is with this at all.
Any help would be much appreciated on this one.
Regards
Mark