I have a client site with a form on their contact page (
www.asi-interiors.net/contact.php). Once submitted, it goes to a usr/sbin/sendmail/thankyou.php where it is validated to ensure fields are filled in and then sent as an email.
The problem is, that it is not sending. The processing of the form is good and the variables for different empty fields works fine, but when all is filled in it does not send. It simply suspends the browser.
There is no serious php code on the contact page, but on the thank you page, it is broken down into a couple sections.
First the validation at the very top of the code, very simple:
<?php
if (!$_POST[name]) {$message = "You must enter your name.\n
"; }
if (!$_POST[phone]) {$message .= "You must enter your phone number.\n
"; }
if (!$_POST[email]) {$message .= "You must enter your E-mail Address.\n
"; }
if (!$_POST[desc]) {$message .= "You must provide a description of your project.\n
"; }
?>
Then the body portion, where it advises of missed fields and redisplays the form or should say thank you for submitting the form once sent:
<?php
echo '
<h1>';
if (isset($message))
{
echo 'Oops, Missed Something</h1></p>
';
echo '<font color="#FF0000">
',$message,'</font>';
$sendmail = FALSE;
}
else
{
echo 'Thank You!</h1></p>
';
echo "Thank you
",$_POST[name]," for taking the time to contact us.\n
";
echo "We will get back to you at
",$_POST[phone]," or
",$_POST[email]," within 2 business days.\n
</p>";
$sendmail = TRUE;
}
if ($sendmail == TRUE)
{
$sendto = 'rob@sovereignwebdesign.com';
$sendsubject = 'Free Estimate Request Form';
$sendbody = 'Name:/t/t/t $_POST[name] /n
Phone: /t/t/t $_POST[phone] /n
Best Time to Call: /t/t $_POST[time2]/n
E-mail Address: /t/t $_POST[email] /n
Description of Project: /t $_POST[desc] /n';
$sendfrom = 'From: ASI Contact Form <info@asi-interiors.net>' . "\r\n";
$sendmenow = TRUE;
}
elseif ($sendmail == FALSE)
{
echo '<form action="',$_SERVER['PHP_SELF'],'" method="post">
<table width="85%" border="0" cellpadding="3">
<tr>
<td width="40%">Name:*</td>
<td width="60%"><input type="text" name="name" ';
if (isset($_POST[name])) {echo 'value="',$_POST[name],'"';}
echo '></td>
</tr>
<tr>
<td>Phone Number:*</td>
<td><input type="text" name="phone" ';
if (isset($_POST[phone])) {echo 'value="',$_POST[phone],'"';}
echo '"></td>
</tr>
<tr>
<td>Best Time to Call:</td>
<td><input type="text" name="time2" ';
if (isset($_POST[time2])) {echo 'value="',$_POST[time2],'"';}
echo '"></td>
</tr>
<tr>
<td>E-mail Address: *</td>
<td><input name="email" type="text" id="email" ';
if (isset($_POST[email])) {echo 'value="',$_POST[email],'"';}
echo '></td>
</tr>
<tr>
<td>Description of Project:*</td>
<td><textarea name="desc" cols="30" rows="4">';
if (isset($_POST[desc])) {echo $_POST[desc];}
echo '</textarea></td>
</tr>
<tr>
<td align="right"> <input type="submit" name="Submit" value="Submit"></td>
<td> <input type="reset" name="Clear" value="Clear"></td>
</tr>
</table>
</form></p>';
}
else
{
echo '
We are sorry, we are having problems with our server,';
echo ' please contact the ';
echo " <a href=\"#\" onclick=\"o='@';o='rob'+o;o='mailto:'+o;o+='sovere ignwebdesign.com' + '?subject=ASI%20Form%20Problems' ;this.href=o;\"><script language=\"JavaScript\"><!--
o='@';o='rob'+o;o+='sovereignwebdesign.com';docume nt.write(o); //-->
</script>webmaster</a></p>";
}
?>
Then at the bottom of the code, I have the mail() function like this:
<?php
if ($sendmenow == TRUE)
{
mail($sendto, $sendsubject, $sendbody, [$sendfrom]);
}
?>
Could someone take a look at this and offer some advise as to why it hangs the browser up when the information is correct and it should be submitted.
Thanks
Rob