Hi Allow,
I have a PHP Contact form that I use on a web site and when I get the emails I only get what check boxes they have checked not what they entered into the text boxes... Code is below, any thoughts?
<?php
function CheckEmailAddress($email){
// first, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
if (isset($_POST['Submit'])){
if (CheckEmailAddress(@$_POST['email'])){
$to = "keith@carlasciofamily.net";
$from = $_POST['email'];
$subject = "CONTACT FORM";
$message = "
<html>
<head>
<title>$subject</title>
<body>
<font face=\"Arial, Helvetica, sans-serif\">
<table width=\"600\" cellpadding=\"1\" cellspacing=\"2\">
<tr bgcolor=\"##CCCCCC\">
<td colspan=\"2\"><strong><font face=\"Arial, Helvetica, sans-serif\">Contact
Form </font></strong></td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td width=\"150\" valign=\"top\" nowrap> <font face=\"Arial, Helvetica, sans-serif\">Company Name:</font></td>
<td valign=\"top\">$companyName</td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td width=\"150\" valign=\"top\" nowrap><font face=\"Arial, Helvetica, sans-serif\">Contact Name:</font></td>
<td valign=\"top\">$contactName</td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td width=\"150\" valign=\"top\" nowrap>Phone: </td>
<td valign=\"top\">$phone</td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td width=\"150\" valign=\"top\" nowrap><font face=\"Arial, Helvetica, sans-serif\">Email:</font> </td>
<td valign=\"top\"><a href=\"mailto:$email\">$email</a></td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td valign=\"top\" nowrap>Message:</td>
<td valign=\"top\">$formmessage</td>
</tr>
<tr bgcolor=\"##f4f4f4\">
<td valign=\"top\" nowrap>Products & Services<br />
that may be of interest:</td>
<td valign=\"top\">".
(isset($_POST['checkbox1'])?$_POST['checkbox1']."<br>\n":"").
(isset($_POST['checkbox2'])?$_POST['checkbox2']."<br>\n":"").
(isset($_POST['checkbox3'])?$_POST['checkbox3']."<br>\n":"").
(isset($_POST['checkbox4'])?$_POST['checkbox4']."<br>\n":"").
(isset($_POST['checkbox5'])?$_POST['checkbox5']."<br>\n":"").
(isset($_POST['checkbox6'])?$_POST['checkbox6']."<br>\n":"").
"</td>
</tr>
</table>
</font>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <'.$from.'>' . "\r\n";
if (mail($to,$subject,$message,$headers)){
unset($_POST);
$usermessage = "Your message has been sent. Thank you!";
}
else{
$usermessave = "There was a problem sending you message. Please try again later.";
}
}
else{
$usermessage = "Please enter a valid email address.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>ABC</title>
<!-- InstanceEndEditable -->
<script language="JavaScript" type="text/javascript" src="common/menu.js"></script>
<!-- InstanceBeginEditable name="head" -->
<script language="JavaScript" type="text/javascript">
<!--
var page = "contact";
//-->
</script>
<!-- InstanceEndEditable -->
<link href="common/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="760" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="homeTable" class="homeTable">
<tr>
<td width="760" valign="top" class="repeatY">
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="329"><a href="default.html"><img src="images/logo_toplt.gif" width="329" height="63" border="0" /></a></td>
<td width="62"><a href="default.html"><img src="images/btnHome.gif" width="62" height="63" border="0" id="1" onmouseover="rollHandler(this.id);" onmouseout="rollHandler(this.id);" /></a></td>
<td width="82"><a href="about.html"><img src="images/btnAbout.gif" width="82" height="63" border="0" id="2" onmouseover="rollHandler(this.id);" onmouseout="rollHandler(this.id);" /></a></td>
<td width="82"><a href="services.html"><img src="images/btnServices.gif" width="82" height="63" border="0" id="3" onmouseover="rollHandler(this.id);" onmouseout="rollHandler(this.id);" /></a></td>
<td width="101"><a href="testimonials.html"><img src="images/btnTestimonials.gif" width="101" height="63" border="0" id="4" onmouseover="rollHandler(this.id);" onmouseout="rollHandler(this.id);" /></a></td>
<td width="104"><a href="contact.php"><img src="images/btnContact.gif" width="104" height="63" border="0" id="5" onmouseover="rollHandler(this.id);" onmouseout="rollHandler(this.id);" /></a></td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
rollHandler(getLitButton(page));
window.onload = function() {
MM_preloadImages('images/btnHome_over.gif','images/btnAbout_over.gif','images/btnServices_over.gif','images/btnTestimonials_over.gif','images/btnContact_over.gif');
if (typeof(page) != "undefined") {
if (page == "home") {
// turn on rss tile background for home page
document.getElementById("homeTable").className = "rssTileGreen";
}
}
}
//-->
</script>
<!-- InstanceBeginEditable name="mainContent" -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="412" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="412" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="550" height="78"><img src="images/header_contact.gif" width="550" height="78" /></td>
<td width="210"><img src="images/headerRt.gif" width="210" height="78" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25"> </td>
<td>
<p>We appreciate your interest in Inc., and if you would like to contact us immediately<br />
please call 888-550-9920 or email us at <a href="mailto:keith@carlasciofamily.net">keith@carlasciofamily.net</a>.</p>
<form id="form" name="form" method="post">
<?php
if (isset($usermessage)){
?>
<div align="center"><font style="color:red;"><?=$usermessage?></font></div>
<?php
}
?>
<table width="100" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#EBEBEB" bgcolor="#F5F5F5">
<tr>
<td colspan="3" valign="top" bgcolor="#EBEBEB"><strong>To handle your inquiry appropriately,<br />
please provide us with some brief information:</strong></td>
</tr>
<tr>
<td align="right" valign="top" nowrap="nowrap">Company Name:</td>
<td valign="top">
<input name="companyName" type="text" id="companyName" value="<?=@$_POST['companyName']?>" tabindex="1" />
</td>
<td rowspan="5" valign="top">
Your Message:
<textarea name="formmessage" cols="40" rows="14" tabindex="11"><?=@$_POST['formmessage']?></textarea>
<input type="submit" name="Submit" value="> Send Message" style="float:right;clear:left;" tabindex="12" />
</td>
</tr>
<tr>
<td align="right" valign="middle" nowrap="nowrap">Contact Name:</td>
<td valign="middle">
<input name="contactName" type="text" id="contactName" value="<?=@$_POST['contactName']?>" tabindex="2" />
</td>
</tr>
<tr>
<td align="right" valign="middle" nowrap="nowrap">Phone:</td>
<td valign="middle">
<input name="phone" type="text" id="phone" value="<?=@$_POST['phone']?>" tabindex="3" />
</td>
</tr>
<tr>
<td align="right" valign="middle" nowrap="nowrap">Email:</td>
<td valign="middle">
<input name="email" type="text" id="email" value="<?=@$_POST['email']?>" tabindex="4" />
</td>
</tr>
<tr>
<td align="right" valign="middle">Products & Services<br />
that may be of interest:
<p></p>
</td>
<td valign="middle" nowrap="nowrap">
<label for="DirMailList">
<input type="checkbox" name="checkbox1" value="Direct Mailing Lists" id="DirMailList" <?=isset($_POST['checkbox1'])?"checked":""?> tabindex="5" />
Direct Mailing Lists</label>
<br />
<label for="EmailMark">
<input type="checkbox" name="checkbox2" value="Email Marketing" id="EmailMark" <?=isset($_POST['checkbox2'])?"checked":""?> tabindex="6" />
Email Marketing</label>
<br />
<label for="IntCamp">
<input type="checkbox" name="checkbox3" value="Integrated Campaigns" id="IntCamp" <?=isset($_POST['checkbox3'])?"checked":""?> tabindex="7" />
Integrated Campaigns</label>
<br />
<label for="DataHyg">
<input type="checkbox" name="checkbox4" value="Data Hygiene or Data Processing" id="DataHyg" <?=isset($_POST['checkbox4'])?"checked":""?> tabindex="8" />
Data Hygiene or Data Processing</label>
<br />
<label for="DataEnh">
<input type="checkbox" name="checkbox5" value="Data Enhancements" id="DataEnh" <?=isset($_POST['checkbox5'])?"checked":""?> tabindex="9" />
Data Enhancements</label>
<br />
<label for="Other">
<input type="checkbox" name="checkbox6" value="Other" id="Other" <?=isset($_POST['checkbox6'])?"checked":""?> tabindex="10" />
Other</label>
</td>
</tr>
</table>
</form>
PHP Form Not Mailing all Info
Moderator: General Moderators
Re: PHP Form Not Mailing all Info
Thanks.. but I kno little to nothing about PHP.. the person who built has since left with no contact info so I am left to try and figure it out...
I went the post but not sure where or what I am supposed to change...
THanks,
Keith
I went the post but not sure where or what I am supposed to change...
THanks,
Keith