Jump to content

html form using php sends email receipt, but not info inputted...


macman

Recommended Posts

So as many have mentioned before, i too am new to php. this is my first attempt. i have built a lengthy html form that needs to send the information to an email. i am using a php code someone gave me ( who was able to get this form to work on his server with his email). embedded in the php body tags is an html thankyou page with some css. when i fill out the form everything links correctly and i receive the email receipt. however the name field is supposed to show up in that email and does not. the only information sent to the destination email from the form is the email address. the inputted information from (line 134 in php code) $themessage does not come through. (e.g. Musher Name shows up but not the actual name entered in the form). any help would be greatly appreciated. i am using cs3 dreamweaver on a mac. testing in safari, if that makes a difference...

 

 

<title>marathonphp</title><?php


// ------- three variables you MUST change below  -------------------------------------------------------
$replyemail="info@beargrease.com";//change to your email address
$valid_ref1="http://www.beargrease.com/marathon_form.html";// chamge "Your--domain" to your domain
$valid_ref2="http://www.beargrease.com/marathon_form.html";// chamge "Your--domain" to your domain
// -------- No changes required below here -------------------------------------------------------------
// email variable not set - load $valid_ref1 page
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 rsvp.php.\");\n";
echo "top.location.href = \"index.html\"; \n// --></script>";
exit;
}

//check user input for possible header injection attempts!
function is_forbidden($str,$check_all_patterns = true)
{
$patterns[0] = 'content-type:';
$patterns[1] = 'mime-version';
$patterns[2] = 'multipart/mixed';
$patterns[3] = 'Content-Transfer-Encoding';
$patterns[4] = 'to:';
$patterns[5] = 'cc:';
$patterns[6] = 'bcc:';
$forbidden = 0;
for ($i=0; $i<count($patterns); $i++)
  {
   $forbidden = eregi($patterns[$i], strtolower($str));
   if ($forbidden) break;
  }
//check for line breaks if checking all patterns
if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(%0a|%0d|\\n+|\\r+)/i", $str);
if ($forbidden)
{
  echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
        The text you entered is forbidden, it includes one or more of the following:
        <br><textarea rows=9 cols=25>";
  foreach ($patterns as $key => $value) echo $value."\n";
  exit();
}
else return $str;
}

$name = is_forbidden($_POST["name"]);
$email = is_forbidden($_POST["email"]);
$thesubject = is_forbidden($_POST["thesubject"]);
$themessage = is_forbidden($_POST["themessage"], false);

$success_sent_msg='<body>
<style type="text/css">
<!--
a {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-style: normal;
font-weight: bolder;
color: #0000FF;
text-decoration: none;
}
a:hover {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-style: normal;
font-weight: bolder;
color: #999999;
text-decoration: underline;
}
body {
background-color: #89702C;
}
.Rfont {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: bolder;
color: #FF0000;
}
-->
</style>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><table width="700" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="registration/header.jpg" alt="registration" width="700" height="216" border="0" usemap="#Map" />
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td bgcolor="#D3C6AD"></td>
              </tr>
          </table></td>
      </tr>
    </table>
      <table width="700" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5EBD2">
        <tr>
          <td><table border="0" cellpadding="0" cellspacing="0">
            <tr bgcolor="#F5EBD2">
              
              </tr>
          </table>
          </td>
        </tr>
      </table>
      <table width="700" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="448" align="center" bgcolor="#F5EBD2">Thank you for registering for the 2010 John Beargrease Full Marathon.<br />
              <span class="Rfont">To complete your registration, you must click on the link below<br />
            and make your Payment.</span><br />
            <br />
            <a href="http://www.beargreaseshop.com/Marathon-Registration-2010_p_150.html" target="_blank">CLICK HERE FOR PAYMENT</a><br /></td>
        </tr>
      </table></td>
    
</table>

<map name="Map" id="Map"><area shape="rect" coords="233,162,689,212" href="home.htm" target="_self" />
</map></body>';

$replymessage = "Hi $musher_name.

Thank you for registering for the 2010 John Beargrease Full Marathon.";

$themessage = "marathon registration \nMusher Name: $musher_name \nMailing Address: $mailing_address \nPhone Day: $phone_day \nPhone Night: $phone_night \nEmail: $email \nFax Number: $fax_number \nDate of Birth: $date_of_birth \nAge: $age \nOccupation: $occupation \nKennel Name: $kennel_name \nBoot Size: $boot_size \nT-shirt Size: $tshirt_size \nSecondary Contact Person: $second_contact \nTeam Owner: $team_owner \nSignature: $disclaimer_signature \nDate: $disclaimer_date \nParticipation in previous Beargrease races: $previous_beargrease \nOther racing experience: $previous_other \nBio: $bio";
mail("$replyemail",
     "$thesubject",
     "$themessage",
     "From: $email\nReply-To: $email");
mail("$email",
     "Receipt: $thesubject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;
?>

<!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>marathon_form</title>
<style type="text/css">
<!--
.style3 {font-size: 14px}
.style4 {font-size: 12px}
body {
background-color: #89702C;
}
.linKsm {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
font-style: normal;
font-weight: bold;
color: #0000FF;
text-decoration: none;
}
.linKlg {
font-family: "Times New Roman", Times, serif;
font-size: 18px;
font-style: normal;
font-weight: bolder;
color: #FF0000;
text-decoration: none;
}
.fontB {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: bolder;
color: #FF0000;
}
a:hover {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
font-style: normal;
font-weight: bolder;
color: #999999;
text-decoration: underline;
}
.fontsm {
font-family: "Times New Roman", Times, serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #FF0000;
}
.style6 {font-family: "Times New Roman", Times, serif; font-size: 16px; font-style: normal; font-weight: bolder; color: #FF0000; text-decoration: none; }
-->
</style>
</head>

<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#F5EBD2"><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="middistance/header.jpg" alt="registration" width="700" height="216" border="0" usemap="#Map" />
          <table width="700" border="0" cellspacing="0" cellpadding="0">
            <tr bgcolor="#F5EBD2">
              <td><table border="0" cellpadding="0" cellspacing="0">
                  
              </table></td>
            </tr>
          </table>
          <table width="700" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>















</td>
            </tr>
          </table>
          <form id="form2" name="form1" method="post" action="marathon.php">
            <table width="75%" border="0" align="center" cellpadding="2" cellspacing="1" summary="table used for form layout">
              <tr>
                <th colspan="2" scope="col">2010 John Beargrease<br />
                  Sled Dog Marathon<br />
                  Duluth, MN<br /></th>
              </tr>
              <tr>
                <td colspan="2" align="center"><strong>Musher Registration - Marathon Race<br />
                  </strong><span class="fontsm">Please enter all information requested. Once submitted proceed to store for payment.</span><strong><br />
                </strong></td>
              </tr>
              <tr>
                <td width="17%" align="left" valign="top"><strong>Entry Fee:</strong></td>
                <td><span class="style3">$275 (US dollars) until 10/01/2009. $305 from 10/02/2009 - 12/31/2009. $325 from 01/01/2010 - 01/18/2010. Entry fees include a $30 nonrefundable Musher Membership.<br />
                      <br />
                  </span><span class="fontB">-DEADLINE FOR REGISTRATION IS 01/22/2010-</span><span class="style3"><br />
                                  </span></td>
              </tr>
              <tr>
                <td><strong>Musher Name:</strong></td>
                <td width="70%"><input name="musher_name" type="text" id="musher_name" size="40" maxlength="100" /></td>
              </tr>
              <tr>
                <td valign="top"><strong>Mailing Address:</strong></td>
                <td><textarea name="mailing_address" cols="40" rows="4" id="mailing_address"></textarea>
                    <br />
                    <span class="style3">City, State, Zip, Country<br />
                      (Please include street address in addition to PO Box)</span><br /></td>
              </tr>
              <tr>
                <td><strong>Phone:</strong></td>
                <td><label>Day
                  <input name="phone_day" type="text" id="phone_day" size="15" maxlength="15" />
                  Night
                  <input name="phone_night" type="text" id="phone_night" size="16" maxlength="15" />
                </label></td>
              </tr>
              <tr>
                <td><strong>Email:</strong></td>
                <td><input name="email" type="text" id="email_address" size="40" maxlength="100" /></td>
              </tr>
		<tr>
                <td><strong>Confirm Email:</strong></td>
                <td><input name="email" type="text" id="email_address" size="40" maxlength="100" /></td>
              </tr>
              <tr>
                <td><strong>Fax Number:</strong></td>
                <td><input name="fax_number" type="text" id="fax_number" size="16" maxlength="15" /></td>
              </tr>
              <tr>
                <td><strong>Date of Birth:</strong></td>
                <td><label>mm/dd/yyyy
                    <input name="date_of_birth" type="text" id="date_of_birth" size="20" maxlength="10" />
                </label></td>
              </tr>
              <tr>
                <td><strong>Age:</strong></td>
                <td><input name="age" type="text" id="age" size="5" maxlength="3" /> 
                  <strong>Occupation:
                  <input name="occupation" type="text" id="occupation" size="25" maxlength="50" />
                  </strong></td>
              </tr>
              <tr>
                <td><strong>Kennel Name:</strong></td>
                <td><input name="kennel_name" type="text" id="kennel_name" size="40" maxlength="100" /></td>
              </tr>
              <tr>
                <td><strong>Boot Size:<br />
                </strong>(no half sizes)</td>
                <td valign="top"><input name="boot_size" type="text" id="boot_size" size="5" maxlength="2" /></td>
              </tr>
              <tr>
                <td><strong>T-shirt Size:</strong></td>
                <td><input name="tshirt_size" type="text" id="tshirt_size" size="5" maxlength="3" /></td>
              </tr>
              <tr>
                <td valign="top"><strong>Secondary Contact Person:</strong></td>
                <td valign="top"><input name="second_contact" type="text" id="second_contact" size="40" maxlength="100" />
                  <span class="style3"><br />
                  Name, phone number of someone we can reach if you will be traveling extensively.</span><br />
                  <br /></td>
              </tr>
              <tr>
                <td valign="top"><strong>Team Owner:</strong></td>
                <td><label>(if different from musher)
                    <input name="team_owner" type="text" id="team_owner" size="40" maxlength="100" />
                </label></td>
              </tr>
              <tr>
                <td valign="top"><strong>Important: </strong></td>
                <td><em>I have read and understand the JBSDM 2010 Official Rules which</em> <em>are available online. Note: when possible we ask that you download/print the rules from our website.</em></td>
              </tr>
              <tr>
                <td valign="top"><strong>Disclaimer:</strong></td>
                <td><span class="style3">I agree to hold the John Beargrease Sled Dog Marathon, Inc., race sponsors and other contributors harmless from any claim or demand based on any alleged action or inaction by myself, my dogs, agents or others acting on my behalf. I also agree to release John Beargrease Sled Dog Marathon, Inc., race sponsors and agents and employees from any claim or demand resulting from injury to myself, my dogs, or my property. Further, I give John Beargrease Sled Dog Marathon, Inc., the unqualified and unrestricted authority to release my name, address, and otherwise collect information and photographs for advertising, public relations, or other purposes.</span></td>
              </tr>
              <tr>
                <td colspan="2"><strong>Signature:
                  <input name="disclaimer_signature" type="text" id="disclaimer_signature" size="25" maxlength="100" />
                Date:
                <input name="disclaimer_date" type="text" id="disclaimer_date" size="20" maxlength="10" />
                </strong></td>
                </tr>
              <tr>
                <td colspan="2" align="center"><span class="fontB">Entry form must be completed in its entirety and must be accompanied by full payment before your entry will be registered!!!!!</span></td>
                </tr>
              <tr>
                <td colspan="2" align="center"><strong>Participation in previous Beargrease races.</strong></td>
                </tr>
              <tr>
                <td colspan="2" align="center">Year / Distance / Position Finished(or DNF) / Awards(if any)<strong>
                    <textarea name="previous_beargrease" cols="60" rows="5" id="previous_beargrease"></textarea>
                </strong></td>
                </tr>
              <tr>
                <td colspan="2" align="center"><strong>Other racing experience.</strong></td>
                </tr>
              <tr>
                <td colspan="2" align="center">Year / Race / Distance / Position Finished(or DNF) / Awards(if any)
                  <textarea name="previous_other" cols="60" rows="5" id="previous_other"></textarea></td>
                </tr>

              <tr>
                <td colspan="2">Please write a short paragraph about yourself. The Beargrease will use this information in publicity releases. (Some things to include: Occupation, number of years in the sport, number of dogs in your kennel, family, other interests, stories from the trail, etc.)</td>
                </tr>
              <tr>
                <td><strong>Bio:</strong></td>
                <td><textarea name="bio" cols="50" rows="5" id="bio"></textarea></td>
              </tr>
              <tr>
                <td colspan="2">Please send a photo of yourself for publishing in the 2010 Official Beargrease Race Program. If possible, email the photo to <a href="mailto:info@beargrease.com" target="_blank" class="linKsm">info@beargrease.com</a>. A photograph can also be sent to the Beargrease Office. A race entry is not complete until your bio and picture are submitted.<br />
                  <strong><em>Pictures must be received in the office by 10/01/2009 to be included in the Race Program.</em></strong><br /></td>
                </tr>

              <tr>
                <td colspan="2" align="center"><strong>The Board of Directors and the Members thank you for your loyal support of the John Beargrease Races.</strong><input type="hidden" name="thesubject" value="Beargrease Marathon Form Submission" /></td>
                </tr>
              <tr>
                <td colspan="2" align="center"><input type="submit" name="Submit" id="Submit" value="Submit" />
                  <input type="reset" name="Reset" id="button" value="Reset" /></td>
                </tr>
              <tr>
                <td colspan="2" align="center"> </td>
              </tr>
              <tr>
                <td colspan="2" align="center"><strong>Beargrease Office: PO Box 500, Duluth MN 55801 Phone: (218) 722-7631 Fax: (218) 625-5302</strong></td>
              </tr>
              <tr>
                <td colspan="2"> </td>
              </tr>
            </table>
          </form></td>
      </tr>
    </table>
</td>
  </tr>
</table>

<map name="Map" id="Map"><area shape="rect" coords="237,294,683,339" href="file:///Macintosh HD/Users/jesseclass/Desktop/new_forms/registration.html" target="_self" alt="registration" />
<area shape="rect" coords="232,162,686,207" href="registration.html" target="_self" alt="registration" />
</map></body>
</html>

 

 

 

Link to comment
Share on other sites

I can't see the line numbers.  Can you just post the small pieces you need help with?

 

As a start, spit the variable out to the screen using var_dump($varName);  If it does not show up, then there is something off with your html or variables.  If it does, then we'll have to look at what you are sending in the email.

Link to comment
Share on other sites

that's the problem is i am not sure what part i need help with. i receive no error messages. what i am sending is $themessage at the very bottom of the php. the receipt is just above that as $replymessage which sends to the email given on the form but $musher_name does not show up.

 

again just a beginner with php, where would i put $varName in the code? then would i test on server to see if info is sent? thankyou for any help you can offer.

Link to comment
Share on other sites

first i tried here

<map name="Map" id="Map"><area shape="rect" coords="233,162,689,212" href="home.htm" target="_self" />
</map></body>';

$replymessage = "Hi $musher_name.

Thank you for registering for the 2010 John Beargrease Full Marathon.";

 

that didn't work so then i tried a few lines down

Thank you for registering for the 2010 John Beargrease Full Marathon.";

$themessage = "marathon registration \nMusher Name: $musher_name \nMailing Address: $mailing_address \nPhone Day: $phone_day \nPhone Night: $phone_night \nEmail: $email \nFax Number: $fax_number \nDate of Birth: $date_of_birth \nAge: $age 

 

Link to comment
Share on other sites

</map></body>';

$replymessage = "Hi $musher_name="joe smith";.

Thank you for registering for the 2010 John Beargrease Full Marathon.";

and then i tried

$themessage = "marathon registration \nMusher Name: $musher_name="joe smith"; \nMailing Address: $mailing_address \nPhone Day: $phone_day \nPhone Night: $phone_night \nEmail: $email \nFax Number: $fax_number \nDate of Birth: $date_of_birth \nAge:

 

these were the only two places $musher_name shows up in the php code

 

Link to comment
Share on other sites

yes, i kept that line, just replaced the previous line of $musher_name="joe smith";

 

something i am wondering, in my forms html code, for the action (after method="post") i have action="marathon.php"> do i need the just the relative link or the complete external link?

Link to comment
Share on other sites

It can never hurt to put the entire link.  Send the lines again up to and including when you send the email along with the result. 

 

also, right before you send the email, do this according to your variable names:

var_dump($subject);

var_dump($message);

 

That will help you debug it.  You'll see if the name is being output or not.  In the message variable, write t $musher_name t.  That way, if it is blank, you'll at least see the two t's.  Your goal is to get $musher_name to have something in it.

 

I gotta go, but I'll check back in the morning.  I think something is probably messed up with the form.  If you can post a link on here to the form and the processing file, I'll take a look at it.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.