I have no idea why, but the form mailer I'm using is not working correctly. Granted, I'm still a newb, but everything in the code looks fine to me.

I'm using a modified version of the free form mailer available at www.TheDemoSite.co.uk

The exact problem is this: I fill out the form, hit submit, and then stare in frustration as the page reloads with a blank form, instead of showing me the confirmation message and sending the email it's supposed to.

Maybe I just need another pair of eyes on this. Please, if anyone can help, I'm lost.

Here's the code I'm working with (which I've attached--found at the bottom of this post--for easier reading, as well):

HTML

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Share Your Experience</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<form name="phpformmailer" action="contact_processCS.php" method="post">
<div style="text-align:left">
<div id="wrapper">

<table id="banner">
	<tr>
    	<td width="732" height="114"></td>
    </tr>
</table>

<div>
	<p class="header">Thank you for choosing company for your service needs.</p>
		<br />
	<p class="header2">Our goal is to provide you with the best possible service, and your input is vital to our success.
		<br />
		<br />
	Please take a few moments to let us know how we are doing.</p>
		<br />
		<br />
</div>

<div id="contact">
	Your first name:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="FirstName" size="30" /></div>
<br />
<br />
<div id="contact">
	Your last name:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="LastName" size="30" /></div>
<br />
<br />
<div id="contact">
	Your telephone number:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="TelephoneNumber" size="30" /></div>
<br />
<br />
<div id="contact">
	Your email address:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="Email" size="50" /></div>
<br />
<br />
<div id="contact">
	Confirm email:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="Email2" size="50" /></div>
<br />
<br />


<div id="tablepos">
<table cellpadding="4" cellspacing="1">
	<tr class="table_head" bgcolor="#64077a">
		<td width="420"></td>
        <td width="50">Strongly<br />Agree</td>
        <td width="50">Agree</td>
      <td width="50">Does Not<br />Apply</td>
      <td width="50">Disagree</td>
      <td width="50">Strongly<br />
      Disagree</td>
	</tr>
    <tr>
    	<td class="cell_left">My telephone calls are answered promptly</td>
        <td class="cell_radio"><input type="radio" name="TelephoneRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="TelephoneRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="TelephoneRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="TelephoneRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="TelephoneRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">company provides timely responses to my requests</td>
        <td class="cell_radio"><input type="radio" name="ResponseRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ResponseRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ResponseRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="ResponseRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="ResponseRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr>
    	<td class="cell_left">company Customer Service representatives are helpful and knowledgeable</td>
        <td class="cell_radio"><input type="radio" name="CSRepsRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="CSRepsRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="CSRepsRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="CSRepsRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="CSRepsRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">My services and events are conducted correctly &amp; professionally</td>
        <td class="cell_radio"><input type="radio" name="ConductedRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ConductedRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ConductedRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="ConductedRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="ConductedRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr>
    	<td class="cell_left">company informs me about new services or service changes</td>
        <td class="cell_radio"><input type="radio" name="InformedRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="InformedRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="InformedRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="InformedRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="InformedRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">company is easy to do business with</td>
    	<td class="cell_radio"><input type="radio" name="EasyRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="EasyRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="EasyRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="EasyRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="EasyRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr>
    	<td class="cell_left">company deals with problems efficiently and effectively</td>
        <td class="cell_radio"><input type="radio" name="ProblemsRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ProblemsRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ProblemsRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="ProblemsRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="ProblemsRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">company offers good value for the price paid</td>
        <td class="cell_radio"><input type="radio" name="ValueRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ValueRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ValueRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="ValueRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="ValueRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr>
    	<td class="cell_left">company services are easy to use</td>
        <td class="cell_radio"><input type="radio" name="ServicesRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ServicesRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="ServicesRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="ServicesRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="ServicesRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">company billing is accurate</td>
        <td class="cell_radio"><input type="radio" name="BillingRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="BillingRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="BillingRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="BillingRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="BillingRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr>
    	<td class="cell_left">company credit terms are clear</td>
        <td class="cell_radio"><input type="radio" name="CreditRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="CreditRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="CreditRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="CreditRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="CreditRadio" value="Strongly Disagree"/></td>
    </tr>
    <tr bgcolor="#d8bbdf">
    	<td class="cell_left">I enjoy doing business with company</td>
        <td class="cell_radio"><input type="radio" name="EnjoyRadio" value="Strongly Agree"/></td>
        <td class="cell_radio"><input type="radio" name="EnjoyRadio" value="Agree"/></td>
        <td class="cell_radio"><input type="radio" name="EnjoyRadio" value="Does Not Apply"/></td>
        <td class="cell_radio"><input type="radio" name="EnjoyRadio" value="Disagree"/></td>
        <td class="cell_radio"><input type="radio" name="EnjoyRadio" value="Strongly Disagree"/></td>
    </tr>
</table>
</div>

<div id="contact">
	Your title:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="Title" size="30" /></div>
<br />
<br />
<div id="contact">
	Your company size:<font class="required">*</font>
    </div>
    <div id="contact_text">
    	<select name="CompanySize">
        	<option value="no value">Choose one...</option>
        	<option value="1-49">1 - 49</option>
            <option value="50-99">50 - 99</option>
            <option value="100-199">100 - 199</option>
            <option value="200-499">200 - 499</option>
            <option value="500-999">500 - 999</option>
            <option value="1000 or more">1000 or more</option>
        </select>
    </div>
<br />
<br />
<div id="contact">
	Number of company locations:<font class="required">*</font>
    </div>
    <div id="contact_text"><input type="text" name="OfficeLocationsNum" size="30" /></div>
<br />
<br />

<div id="sq">
What can we do to improve our relationship with you?
<br />
	<div id="textarea">
   	  <textarea name="ImproveOurRelationship" rows="4" cols="60"></textarea>
	</div>
Do you have any additional comments regarding your experience with Connex?
<br />
	<div id="textarea">
    	<textarea name="AdditionalComments" rows="4" cols="60"></textarea>
    </div>
<input type="checkbox" name="check[]" value="contact me" />
I have more to say, and would like to be contacted.
<div id="textarea">
The best time to call is between:&nbsp;&nbsp;
<input type="text" name="ContactTime1" size="10" />&nbsp;&nbsp;
and&nbsp;&nbsp;
<input type="text" name="ContactTime2" size="10" />&nbsp;&nbsp;
<br />
<br />
</div>
<div class="ampm">Please be sure to indicate AM or PM and your local time zone.</div>
</div>
<div id="submit">
<input type="button" value="Send" name="B1" onclick="javascript:validateForm()" />
       Fields marked with a <font size="+2" color="#597cce">*</font> are required</div>
</div>
</div>
<div id="footer">



</div>

</form>

<script language="JavaScript" type="text/javascript"><!--
function validateForm(phpformmailer) 
{
 var okSoFar=true
 with (document.phpformmailer)
 {
  var foundAt = Email.value.indexOf("@",0)
  if (foundAt < 1 && okSoFar)
  {
    okSoFar = false
    alert ("Please enter a valid email address.")
    Email.focus()
  }
  var e1 = Email.value
  var e2 = Email2.value
  if (!(e1==e2) && okSoFar)
  {
    okSoFar = false
    alert ("The email addresses you entered do not match.  Please re-enter.")
    Email.focus()
  }
  if (FirstName.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter your first name.")
    FirstName.focus()
  }
  if (LastName.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter your last name.")
    LastName.focus()
  }
  if (TelephoneNumber.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter your telephone number.")
    TelephoneNumber.focus()
  }
  if (Title.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter your title.")
    Title.focus()
  }
  if (OfficeLocationsNum.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter your company's number of locations.")
    OfficeLocationsNum.focus()
  }
  if (okSoFar==true)  submit();
 }
}
// --></script>


</body>
</html>

Just in case, here's the CSS:

@charset "utf-8";
/* CSS Document */


body { /* <----Gives 1em value of 10px----> */
	font-size: 62.5%;
	}
	
body, html { /* <----IE centering hack----> */
	text-align:center;
	}

/* page style */

#banner {
	background-image:url(banner.jpg);
	background-position:left;
	background-position:top;
	background-repeat:no-repeat;
	min-height:114px;
	max-width:732px;
	}

.hidden {
	display:none;
	}

#wrapper {
	height:100%;
	width:750px;
	min-width:732px;
	max-width:732px;
	margin:0 auto;
	text-align:left;
	}

/* end page style */

/* page head style */

.header {
	font-family:Tahoma;
	color:#64077a;
	font-size:2em;
	font-weight:bold;
	}
	
.header2 {
	font-family:Tahoma;
	color:#995ca7;
	font-size:1.4em;
	font-weight:bold;
}

/* end page head style */

/* contact info style */

#contact {
	font-family:Arial, Helvetica, sans-serif;
	font-size:1.5em;
	float:left;
	width:35%;
	padding-bottom:.6em;
	padding-top:.2em;
	clear:left;
	}

#contact_text {
	float:right;
	width:65%;
	padding-bottom:.6em;
	padding-top:.1em;
	clear:right;
	}
/* end contact info style */

/* table style */

#tablepos {
	clear:both;
	padding-top:2em;
	padding-bottom:2.6em;
	}
	
.table_head {
	font-family:Tahoma;
	font-size:1em;
	font-weight:bold;
	color:#FFFFFF;
	text-align:center;
	}

.cell_left {
	font-family:Arial, Helvetica, sans-serif;
	font-size:1.2em;
	text-align:left;
	}

.cell_radio {
	text-align:center;
	}

/* end table style */

/* survey questions style */

#sq {
	font-family:Arial, Helvetica, sans-serif;
	font-size:1.5em;
	padding-top:2em;
	}

#textarea {
	padding-left:1em;
	padding-top:1em;
	padding-bottom:1em;
	}

.ampm {
	font-family:Tahoma;
	color:#64077a;
	font-size:.7em;
	font-weight:bold;
	}

/* end survey questions style */

#submit {
	text-align:right;
	font-family:Tahoma;
	color:#995ca7;
	font-size:1em;
	font-weight:bold;
	}

.required {
	font-family:Tahoma;
	color:#597cce;
	font-weight:bold;
	}

And finally, the PHP:

<?php

$replyemail="email@email.com";
$subject="Customer Experience Survey";
$valid_ref1="http://formmailer/survey.html";
$valid_ref2="http://formmailer/survey.html";

if (!isset($_POST['email']))
{
 echo "<script language=\"JavaScript\"><!--\n ";
 echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
 exit;
}

$ref_page=$_SERVER["HTTP_REFERER"];
$valid_referrer=0;
if($ref_page==$valid_ref1) $valid_referrer=1;
elseif($ref_page==$valid_ref2) $valid_referrer=1;
if(!$valid_referrer)
{
 echo "<script language=\"JavaScript\"><!--\n alert(\"ERROR - not sent.\\n\\nCheck your 'valid_ref1' and 'valid_ref2' are correct within contact_process.php.\");\n";
 echo "top.location.href = \"survey.html\"; \n// --></script>";
 exit;
}

$FirstName = ($_POST["FirstName"]);
$LastName = ($_POST["LastName"]);
$TelephoneNumber = ($_POST["TelephoneNumber"]);
$Email = ($_POST["Email"]);
$TelephoneRadio = ($_POST["TelephoneRadio"]);
$ResponseRadio = ($_POST["ResponseRadio"]);
$CSRepsRadio = ($_POST["CSRepsRadio"]);
$ConductedRadio = ($_POST["ConductedRadio"]);
$InformedRadio = ($_POST["InformedRadio"]);
$EasyRadio = ($_POST["EasyRadio"]);
$ProblemsRadio = ($_POST["ProblemsRadio"]);
$ValueRadio = ($_POST["ValueRadio"]);
$ServicesRadio = ($_POST["ServicesRadio"]);
$CreditRadio = ($_POST["CreditRadio"]);
$EnjoyRadio = ($_POST["EnjoyRadio"]);
$Title = ($_POST["Title"]);
$CompanySize = ($_POST["CompanySize"]);
$OfficeLocationsNum = ($_POST["OfficeLocationsNum"]);
$ImproveOurRelationship = ($_POST["ImproveOurRelationship"]);
$AdditionalComments = ($_POST["AdditionalComments"]);
$check_msg = "";
$ContactTime1 = ($_POST["ContactTime1"]);
$ContactTime2 = ($_POST["ContactTime2"]);

foreach($_POST["check"] as $value) {
	$check_msg .= "Please $value\n";
}


$success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
                   <p align="center"><strong>Your feedback has been sent.</strong></p>
                   <p align="center">We greatly appreciate you taking the time to share your thoughts.</p>
                   <p align="center">Feedback like yours gives us the ability to create innovative service solutions to drive your business now and in the future.</p>
		   <p align="center">For more information on how we can help you get more done, please visit www.website.com</p>';

$replymessage = "Hello $Title $FirstName $LastName

This email is to confirm we have successfully received your submission.

Once again, thank you for your feedback.  We hope your experience with us has been a pleasant one.

Please DO NOT reply to this email.";

$body = "Name: $FirstName $LastName\n\nTelephone Number: $TelephoneNumber\n\n
				My telephone calls are answered promptly: $TelephoneRadio\n
				company provides timely responses to my requests: $ResponseRadio\n
				company Customer Service representatives are helpful and knowledgeable: $CSRepsRadio\n
				My services and events are conducted correctly & professionally: $ConductRadio\n
				company informs me about new services or service changes: $InformedRadio\n
				company is easy to do business with: $EasyRadio\n
				company deals with problems efficiently and effectively: $ProblemsRadio\n
				company offers good value for the price paid: $ValueRadio\n
				company services are easy to use: $ServicesRadio\n
				company billing is accurate: $BillingRadio\n
				company credit terms are clear: $CreditRadio\n
				I enjoy doing business with company: $EnjoyRadio\n
				Title: $Title\n\nCompany size: $CompanySize\n\nNumber of company locations: $OfficeLocationsNum\n\n
				What we can do to improve our relationship:\n$ImproveOurRelationship\n\n
				Additional comments:\n$AdditionalComments\n\n
				$check_msg between $ContactTime1 and $ContactTime2";
mail("$replyemail",
     "$subject",
     "$body",
     "From: $email");
mail("$email",
     "Receipt: $subject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;

?>

Thanks so, so much in advance for any help or pointers you may be able to provide.

- Devin

Recommended Answers

All 4 Replies

Right i see,
The problem is on the processor there is a command which says:

if (!isset($_POST['email']))

so if email post is not set it will send you back to the form i presume however on the form the field is called Email which PHP will treat as a diferent post variable to email:
Basicaly as PHP is a sort of UNIX language a capital at the start of Email on the form will be diferent to the variable email in the processor
change the if line to:

if (!isset($_POST['Email']))

And try that
Regards,
Sam Rudge

And just like that, the headache's gone! Thank you so, so much! Worked like a charm, of course. Can't believe I didn't see that myself.

- Devin

I cant help you sorry

I cant help you sorry

You more then welcome to reply to any thread without solution or if you believe have better solution. However opening old thread to just say "sorry, I have no clue" is not tolerated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.