Log in

View Full Version : Email Form Error



jkswebsite
01-06-2007, 11:21 PM
Hi everyone, I'm new. Right now I am designing a site for someone, Qualityremodelinginc.net. Keep in mind it's under construction, but I need help on the Estimate page. He wants a form that people can fill out their information and check what services they need an estimate for, and click submit and there should be one new email in his box. I have read some tutorials, but it still doesnt work. This is what my form html looks like now, or you can preview it at Qualityremodelinginc.net/Estimates.html (http://www.Qualityremodelinginc.net/Estimates.html)

----------------------------------------

</body>

<li>
<p align="left"><font size="5"><font color="#663300">Phone:</font> (773)
509-0200</font>
<li>
<p align="left"><font size="5"><font color="#663300">Fax:</font> (773)
539-2177</font>
</ul>


<form method="POST" action="contact.php">

<p style="text-align: left"><b>First Name:
</b>
<input type="text" name="First">
<p style="text-align: left"><b>Last Name:
</b>
<input type="text" name="Last">
<p style="text-align: left"><b>Address:
</b>
<input type="text" name="Address" size="48"><b>

Unit #:</b><input type="text" name="Address0" size="21"><p style="text-align: left">
<b>City:</b>
<input type="text" name="City">
<p style="text-align: left"><b>State:
</b>
<input type="text" name="State">
<p style="text-align: left"><b>Zip:
</b>
<input type="text" name="Zip">
<p style="text-align: left"><b>Phone:
</b>
<input type="text" name="Telephone">&nbsp;&nbsp; <b>Cell: </b>
<input type="text" name="Cell">&nbsp; <b>Work:</b>
<input type="text" name="Work">
<p style="text-align: left"><b>Email:</b>
<input type="text" name="Email" size="48"><br>
<br>

<b>Services Requested:</b><form method="post" action="form.php">
<p style="text-align: left">
<input type="checkbox" name="services[]" value="Kitchen">Kitchen</input><br>
<input type="checkbox" name="services[]" value="Bathroom">Bathroom</input><br />
<input type="checkbox" name="services[]" value="Basement">Basement</input><br />
<input type="checkbox" name="services[]" value="Porch/Deck">Porch/Deck</input><br />
<input type="checkbox" name="services[]" value="Roofing">Roofing</input><br />
<input type="checkbox" name="services[]" value="Room Addition">Room Addition</input><br />
<input type="checkbox" name="services[]" value="Dormer/Attic">Dormer/Attic</input><br />
<input type="checkbox" name="services[]" value="Siding">Siding</input><br />
<input type="checkbox" name="services[]" value="Windows">Windows</input><br />
<input type="checkbox" name="services[]" value="Tuckpointing">Tuckpointing</input></p>
<p style="text-align: left">Other:
<input type="text" name="Other"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="submit" value="Submit" />

</form>
<p>

----------------------------------------

And then I heard you need a contact.php page so I made one. I didn't really edit this while I edited the form, so it matches the original (which is totally different!) Well here is the Contact.php html

<?php // contact.php

if (isset($_POST['services']))
{
echo "You chose: " . join(', ', $_POST['services']) . ".\n";
}

echo "<br />\n";
echo "<a href=\"Error.html\">Choose again</a>\n";


// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "Jkk088@sbcglobal.net";
$Subject = Trim(stripslashes($_POST['Subject']));
$First = Trim(stripslashes($_POST['First']));
$Last = Trim(stripslashes($_POST['Last']));
$Company = Trim(stripslashes($_POST['Company']));
$Address = Trim(stripslashes($_POST['Address']));
$Telephone = Trim(stripslashes($_POST['Telephone']));
$Mobile = Trim(stripslashes($_POST['Mobile']));
$Website = Trim(stripslashes($_POST['Website']));

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

// prepare email body text
$Body = "";
$Body .= "First: ";
$Body .= $First;
$Body .= "\n";
$Body .= "Last: ";
$Body .= $Last;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "Mobile: ";
$Body .= $Mobile;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$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=Thanks.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=Error.html\">";
}
?>



----------------------------------------

Well I hope you all can help cause I am pretty clueless. Thank you SO much, and you all are very intelligent. Thanks again. My email is Jkk088@sbcglobal.net and my aim is Jkk088. So im me or email me. This form is very important to me and I know you guys can help.

//JK

thetestingsite
01-07-2007, 02:55 AM
What's the error that you are getting? The only thing that I can see that's wrong with it (just glancing at it) is the fact that you close the php tag twice.

The following (in red) should be removed:



echo "<a href=\"Error.html\">Choose again</a>\n";
?>

// get posted data into local variables


Remove that, then post the error that you are getting (if any) and it will probably get resolved.

Hope this helps.

jkswebsite
01-07-2007, 04:48 PM
Okay thank you, I changed it but it still doesnt work. Any other changes I could make?

NineTwoZero
01-07-2007, 04:54 PM
can u save php in a .html? :o

NineTwoZero
01-07-2007, 04:58 PM
and i would recommend usin CSS

mburt
01-07-2007, 04:59 PM
can u save php in a .html?
No, the php code will appear as plain text, you have to have the .php extension in your file name.

NineTwoZero
01-07-2007, 05:05 PM
well thats his problem.. he's saved everything as a .html..

thetestingsite
01-07-2007, 05:15 PM
No, the php code will appear as plain text, you have to have the .php extension in your file name.

You actually could save php code as HTML, but you would need to change the MIME type



application/x-httpd-php .html


in the httpd.conf file. But normally you cannot save it as HTML.

NineTwoZero
01-07-2007, 05:19 PM
well i dont think he did that(changed MIMEtype).. but we'll have to wait until he gets back to know for sure :p

djr33
01-07-2007, 09:47 PM
Not the issue at all. The first page is just html.

The action of the form (page it is sent to) is 'contact.php'. Read the comment after the <?php tag in the first post.

mburt
01-07-2007, 11:59 PM
Ah, I thought he was talking about the php page. I used to always leave my "form" pages as .html, but now I change all my pages to .php, because I usually interact all my pages with php on my site.

djr33
01-08-2007, 12:05 AM
Yeah, same, about using .php for all pages.

jkswebsite
01-08-2007, 02:43 AM
Wow ok a lot of advice. Let me see. So I need to change it to php?