|
Posted by rcoan@chaparralboats.com on 02/28/07 14:53
ok, this is my first attempt at php and this all seemed simple enough
when I started. Well everything's working except one thing.
This page is being passed emailaddress in a query string:
http://www.chaparralmedia.net/brochureRequests/contact.htm?emailaddress=r_coan%40hotmail.com
How do I get that from contact.htm to a varible in my contact.php
page? I'm trying to make the php script send an email with the form
data to the email address (emailaddress) but I can't seem to get it to
work.
I'm lost... and frustrated.... I spent all day yesterday working on
this. An hour getting the form and my varibles ready, then the rest
of the day trying different things to get this to work. Any help will
be greatly appreciated as I was supposed to have this live
yesterday :~(
Here's my php.
?php
// get posted data into local variables
$EmailFrom = "rcoan@chaparralboats.com";
$EmailTo = $_GET['emailaddress'];
$Subject = "Chaparral Boats Lead";
$Name = Trim(stripslashes($_POST['Name']));
$Address1 = Trim(stripslashes($_POST['Address1']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Zip = Trim(stripslashes($_POST['Zip']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Email = Trim(stripslashes($_POST['Email']));
$ssi = Trim(stripslashes($_POST['ssi']));
$ssx = Trim(stripslashes($_POST['ssx']));
$sig = Trim(stripslashes($_POST['sig']));
$sun = Trim(stripslashes($_POST['sun']));
$dvd = Trim(stripslashes($_POST['dvd']));
// validation
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Address1)=="") $validationOK=false;
if (Trim($City)=="") $validationOK=false;
if (Trim($State)=="") $validationOK=false;
if (Trim($Zip)=="") $validationOK=false;
if (Trim($Phone)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "The following person has requested more information on
Chaparral Boats. Please send Brochures and/or DVD's in a timely
manner. If you should require extra materials please contact
Chaparral.";
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address1;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State/Providence/Territory: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Zip Code: ";
$Body .= $Zip;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "EmailAddress: ";
$Body .= $EmailAddress;
$Body .= "\n";
$Body .= "SSiBrochure? ";
$Body .= $ssi;
$Body .= $ssx;
$Body .= $sun;
$Body .= "\n";
$Body .= "SignatureBrochure? ";
$Body .= $sig;
$Body .= "\n";
$Body .= "DVD? ";
$Body .= $dvd;
$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=er.htm\">";
}
?>
==========================================================================
Here's my 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>
<style type="text/css">
<!--
..style4 {
color: #CC0000;
font-weight: normal;
}
..style6 {
color: #003366;
font-size: large;
}
..style7 {color: #CC0000}
-->
</style>
</head>
<body>
<form method="POST" action="contact.php">
<div align="left">
<p><img src="images/Chap_Logo_Chrome_Wet.jpg" alt="Chaparral Boats
Request Information | Brochures | DVD's " width="360" height="139" /></
p>
<p class="style6"> Information Request Form</p>
<p class="style7">Fields marked (*) are required </p>
</div>
<input name="emailaddress" id="emailaddress" value="<%=emailaddress
%>">
<p align="left">Name:*
<input type="text" name="Name">
<p align="left">Address:*
<textarea name="Address1"></textarea>
<p align="left">City:*
<input type="text" name= "City">
<p align="left">State or Province:*
<input type="text" name="State">
<p align="left">Zip Code:*
<input type="text" name="Zip">
<p align="left">Phone:*
<input type="text" name="Phone">
<p align="left">Email Address:*
<input type="text" name="Email">
<p align="left">==============================================
<p align="left"><b>Brochure Request</b><br />
<br />
<input type="checkbox" name="ssi">SSi Sportboats<br />
<input type="checkbox" name="ssx">SSX Sportdecks<br />
<input type="checkbox" name="sig">Signature Cruisers<br />
<input type="checkbox" name="sun">Sunesta Deckboats<br />
<p align="left">==============================================
<p align="left"><b>DVD Request</b><br />
<input type="radio" name="dvd" value="SendDVD" />
Yes <br />
<input type="radio" name="dvd" value="NoDVD" checked/>
No
<p align="left">
<input type="checkbox" name="emailUpdates" vlaue="checked" checked/>
I would like to receive email discounts and pre-release product
information from Chaparral Boats.<br /><br />
<p align="left"><span class="style4">All information submitted is held
confidential and not distributed to third parties.<br />
</span><br />
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
==============================================================================
==============================================================================
What can I do to make this happen? I'm at my wits end.... I've
mulled over this simple code for waaayyyy too many hours and I'm in
the same place this morning as I was yesterday morning at this time.
Navigation:
[Reply to this message]
|