Click to See Complete Forum and Search --> : Trouble with contact us page


alexshields
09-18-2007, 03:10 PM
I have this contact us page, located at: http://www.behaviorconsultingservices.com/contactus.htm

I love the page, but have so far been unable to direct the emails to the address I want them sent to when someone presses submit. What am I missing in the code pasted below?

Thank you!!!


<HTML>
<HEAD>
<TITLE>Thank you</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!-- ImageReady Preload Script (index.psd) -->

<!-- End Preload Script -->
</HEAD>
<link href="css/styles.css" rel="stylesheet" type="text/css">
<center>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<!-- ImageReady Slices (index.psd) -->
<table width="775" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" rowspan="2" background="images/nright2.gif"><img src="images/title.gif" width="568" height="88"></td>
<td width="166"><img src="images/main4.gif" width="166" height="69"></td>
<td width="41" rowspan="2"><img src="images/nmain5.gif" width="41" height="88"></td>
</tr>
<tr>
<td><a href="contactus.htm"><img src="images/contactus.gif" width="166" height="19" border="0"></a></td>
</tr>
<tr>
<td width="121" rowspan="3" bgcolor="#2F2F2F">&nbsp;</td>
<td width="85" valign="top" bgcolor="#2F2F2F"><img src="images/main2.gif" width="85" height="23"><a href="index.htm"><img src="images/buttonhome.gif" width="85" height="21" border="0"></a><a href="aba.html"><img src="images/buttonaba.gif" width="85" height="21" border="0"></a><a href="homebased.html"><img src="images/buttonhomebased.gif" width="85" height="21" border="0"></a><a href="school.html"><img src="images/buttonsch.gif" width="85" height="21" border="0"></a><a href="clinic.html"><img src="images/buttonclinic.gif" width="85" height="21" border="0"></a><a href="about.html"><img src="images/buttonaboutgreen.gif" width="85" height="21" border="0"></a><a href="faq.html"><img src="images/buttonfaq.gif" width="85" height="21" border="0"></a><a href="links.html"><img src="images/buttonlinks.gif" width="85" height="21" border="0"></a></td>
<td colspan="2" rowspan="3" align="center" valign="top"><p>Thank you for your email. We will contact you shortly. </p>
<table width="500" border="0" cellspacing="0" cellpadding="10">
<tr>
<td colspan="2"><h2 align="center"><?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "rhonda@behavorconsultingservices.com";
$Subject = "user filled in contact form.";
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>


&nbsp;</h2>
</td>
</tr>
</table></td>
<td rowspan="2" valign="top" nowrap background="images/nright.gif"><img src="images/nmain6.gif" width="41" height="180" align="top"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
</tr>
<tr>
<td valign="bottom" bgcolor="#2E2E2E"><img src="images/thisisme.gif" width="85" height="275"></td>
<td valign="bottom" background="images/nright.gif"><img src="images/shadowright.gif" width="41" height="145"></td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right"><img src="images/down.gif" width="537" height="16"></td>
<td valign="bottom"><img src="images/brcorner.gif" width="41" height="16"></td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right" valign="top" background="images/b_links.gif"><a href="index.htm">Home</a> | <a href="aba.html">ABA</a> | <a href="homebased.html">Home Based</a> | <a href="school.html">School Based</a> | <a href="clinic.html">Clinic Based</a> | <a href="about.html">About Us</a> | <a href="contactus.htm">Contact Us</a></td>
<td rowspan="2" valign="bottom" background="images/nright2.gif">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right" valign="top" background="images/b_links.gif">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="371">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<!-- End ImageReady Slices -->
</BODY>
</center>
</HTML>

alexshields
09-18-2007, 03:14 PM
Not Found
The requested URL /error.htm was not found on this server.

TJ111
09-18-2007, 03:17 PM
OUCH! Non CSS/table based layout hurt the eyes. First of all I'd recommend never posting your full email address anywhere on the net. When it's in PHP such as your's its ok, but posting it here on the forums isn't a smart idea. Not that anyone here would steal it, just web grabbers and the like.

I didn't read your entire script, but I think you might just have a typo for the $emailTo variable:
behavorconsultingservices.com
behaviorconsultingservices.com
?

alexshields
09-18-2007, 03:21 PM
You are right. I fixed the typo though and it still did not work. Should I have built the whole thing differently? What other problems might be there?

TJ111
09-18-2007, 03:27 PM
Saying as how no matter what the user is getting redirected to another page, I don't really see any reason for it to have an HTML on it. I'd put it on its own page w/no other code to make it easier to read/debug.

alexshields
09-18-2007, 03:31 PM
I really like it nested into the site, is there any way to make it work from within the page?

TJ111
09-18-2007, 03:41 PM
I sent a test email and got a 404 no found error. You are redirecting to site's that don't exist, although that shouldn't effect the email part of the page.

What I'm saying is the user will never get to see the page this script is on, as they will get redirected immediately to a different page. I'd say either remove the redirects or remove the HTML.

As far as the mail not sending, it could be caused by this:

$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
...
if (Trim($EmailFrom)=="") $validationOK=false;

You are trimming that string twice. Whether or not it would have any negative effect, I doubt it. But that's the only realproblem I'm seeing.

alexshields
09-18-2007, 03:44 PM
What should I have it re-direct to? Perhaps back to the index page? If so, where do I change that in the code?

Should I remove the second of the repetitive lines?
if (Trim($EmailFrom)=="") $validationOK=false;

TJ111
09-18-2007, 03:49 PM
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
Those are the redirects. Although why this script would use meta redirects who knows. Change the url to whatever you see fit. As fr the double trims, you could try to make it like this:

if ($EmailFrom=="") $validationOK=false;
Doubt it will do anything but its always worth a shot.

alexshields
09-18-2007, 03:57 PM
Thank you, it works now! You have been an amazing help!

alexshields
09-18-2007, 04:06 PM
Why can I not re-direct to an html page that simply says "thanks"?
Here is the code for the page to re-direct to:

<HTML>
<HEAD>
<TITLE>Welcome to Behavior Consulting Services</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!-- ImageReady Preload Script (index.psd) -->

<!-- End Preload Script -->
</HEAD>
<link href="css/styles.css" rel="stylesheet" type="text/css">
<center>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<!-- ImageReady Slices (index.psd) -->
<table width="775" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" rowspan="2" background="images/nright2.gif"><img src="images/title.gif" width="568" height="88"></td>
<td width="166"><img src="images/main4.gif" width="166" height="69"></td>
<td width="41" rowspan="2"><img src="images/nmain5.gif" width="41" height="88"></td>
</tr>
<tr>
<td><a href="contactus.htm"><img src="images/contactus.gif" width="166" height="19" border="0"></a></td>
</tr>
<tr>
<td width="121" rowspan="3" bgcolor="#2F2F2F">&nbsp;</td>
<td width="85" valign="top" bgcolor="#2F2F2F"><img src="images/main2.gif" width="85" height="23"><a href="index.htm"><img src="images/buttonhomegreen.gif" width="85" height="21" border="0"></a><a href="aba.html"><img src="images/buttonaba.gif" width="85" height="21" border="0"></a><a href="homebased.html"><img src="images/buttonhomebased.gif" width="85" height="21" border="0"></a><a href="school.html"><img src="images/buttonsch.gif" width="85" height="21" border="0"></a><a href="clinic.html"><img src="images/buttonclinic.gif" width="85" height="21" border="0"></a><a href="about.html"><img src="images/buttonabout.gif" width="85" height="21" border="0"></a><a href="faq.html"><img src="images/buttonfaq.gif" width="85" height="21" border="0"></a><a href="links.html"><img src="images/buttonlinks.gif" width="85" height="21" border="0"></a></td>
<td colspan="2" rowspan="3" align="center" valign="top"><table width="500" border="0" cellspacing="0" cellpadding="10">
<tr>
<td colspan="2"><h2 align="center"><strong>Thank you for contacting us, someone will reply to your email soon.</strong></h2>
</tr>
</table></td>
<td rowspan="2" valign="top" nowrap background="images/nright.gif"><img src="images/nmain6.gif" width="41" height="180" align="top"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
</tr>
<tr>
<td valign="bottom" bgcolor="#2E2E2E"><img src="images/thisisme.gif" width="85" height="275"></td>
<td valign="bottom" background="images/nright.gif"><img src="images/shadowright.gif" width="41" height="145"></td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right"><img src="images/down.gif" width="537" height="16"></td>
<td valign="bottom"><img src="images/brcorner.gif" width="41" height="16"></td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right" valign="top" background="images/b_links.gif"><a href="index.htm">Home</a> | <a href="aba.html">ABA</a> | <a href="homebased.html">Home Based</a> | <a href="school.html">School Based</a> | <a href="clinic.html">Clinic Based</a> | <a href="about.html">About Us</a> | <a href="contactus.htm">Contact Us</a></td>
<td rowspan="2" valign="bottom" background="images/nright2.gif">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#2F2F2F">&nbsp;</td>
<td valign="bottom" bgcolor="#2E2E2E">&nbsp;</td>
<td colspan="2" align="right" valign="top" background="images/b_links.gif">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="371">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<!-- End ImageReady Slices -->
</BODY>
</center>
</HTML>

alexshields
09-18-2007, 04:09 PM
Shoot! Now it is not redirecting to anything, it keeps putting php on the end of whatever address I tell it to re-direct to.

TJ111
09-18-2007, 04:09 PM
You can very easily, just change the URL's in the print commands.


if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}

alexshields
09-18-2007, 04:14 PM
This is what I have changed it to:
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.behaviorconsultingservices.com/thanks.html">";
}

And it keeps trying to re-direct to http://www.behaviorconsultingservices.com/contact.php

I don't understand why??

TJ111
09-18-2007, 04:14 PM
Don't accidentally change that backslash, that is required there. Change everything before it.

alexshields
09-18-2007, 04:17 PM
That was it, thanks!

TJ111
09-18-2007, 04:19 PM
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.behaviorconsultingservices.com/thanks.html\">";
}
Your not properly escaping that quotation mark.

It could be that your neet meeting the conditionals requirements and are getting redirected elsewhere.