Jump to content

PHP email form help - URGENT PLEASE


786ridz

Recommended Posts

Hey,

 

I'm trying to get my PHP email script to send the following HTML form:

 

 

<form id="form1" name="form1" method="post" action="questionaire.php">
        <table width="100%" border="0" cellspacing="0" cellpadding="6">
          <tr>
            <td colspan="3" align="center" valign="middle" scope="col"><div align="left" class="style2">
              <div align="center" class="style20">Please help us and fill out this questionaire form</div>
            </div></td>
          </tr>
          <tr>
            <td colspan="3" align="center" valign="middle" scope="col"> </td>
          </tr>
          
          <tr>
            <td colspan="3" scope="col"><div align="left"><span class="style2">Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project?</span></div></td>
          </tr>
          <tr>
            <td width="34%"><div align="left" class="style18">
              <p>
                <label></label>
                <label>
                <input type="radio" name="Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project?" value="yes" id="Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project?_0" />
Yes</label>
                <br />
                <label>
                <input type="radio" name="Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project?" value="no" id="Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project?_1" />
No</label>
                <br />
              </p>
            </div></td>
            <td width="66%"><span class="style19"></span></td>
          </tr>
          <tr>
            <td colspan="3"><div align="left" class="style2">Where would you expect to purchase THE TILE SPACER PUNCH?</div></td>
          </tr>
          <tr>
            <td align="left" valign="top"><div align="center">
              <label for="label4"></label>
            </div>
              <div align="center"></div>
              <div align="left">
                <input type="checkbox" name="home improvement stores " id="home improvement stores " />
                <span class="style2">
                <label for="home improvement stores ">home improvement stores<br />
                <input type="checkbox" name="online tool suppliers " id="online tool suppliers " />
                online tool suppliers<br />
                <input type="checkbox" name="local hardware shop " id="local hardware shop " />
                local hardware shop <br />
                <input type="checkbox" name="tiling stores " id="tiling stores " />
                tiling stores<br />
                <input type="checkbox" name="tool suppliers " id="tool suppliers " />
                tool suppliers<br />
                <input type="checkbox" name="supermarkets (tool section) " id="supermarkets (tool section) " />
                supermarkets (tool section)                </label>
                </span>
                <span class="style21">
                <label for="home improvement stores "></label>
                </span>
                <label for="home improvement stores "><br />
                </label>
              </div>
              <div align="left"></div></td>
            <td><span class="style19"></span></td>
          </tr>
          
          
          <tr>
            <td colspan="3" class="style2"> <div align="left" class="style2">At what price would you expect to purchase THE TILE SPACER PUNCH?</div></td>
          </tr>
          <tr>
            <td><div align="left">
              <p class="style18">
                <label>
                  <input type="radio" name="What price would you expect to purchase THE TILE SPACER PUNCH?" value="£1.99 - £2.99" id="What price would you expect to purchase THE TILE SPACER PUNCH?_0" />
                  £1.99 - £2.99</label>
                <br />
                <label>
                  <input type="radio" name="What price would you expect to purchase THE TILE SPACER PUNCH?" value="£2.99 - £3.99" id="What price would you expect to purchase THE TILE SPACER PUNCH?_1" />
                  £2.99 - £3.99</label>
                <br />
              </p>
            </div></td>
            <td><span class="style19"></span></td>
          </tr>
          <tr>
            <td colspan="3"><div align="left" class="style2">If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch?</div></td>
          </tr>
          <tr>
            <td><div align="left"><span class="style15"><span class="style19"><span class="style19"></span></span></span>
              <p>
                <label>
                  <input type="radio" name="If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch?" value="yes" id="If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch?_0" />
                  <span class="style18">Yes</span></label>
                <span class="style18"><br />
                <label>
                  <input type="radio" name="If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch?" value="no" id="If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch?_1" />
                  No</label>
                </span><br />
              </p>
            </div></td>
            <td><span class="style19"></span></td>
          </tr>
          <tr>
            <td colspan="3"><div align="left" class="style2">If you were tiling in your home, would you purchase the punch for the project?</div></td>
          </tr>
          <tr>
            <td><div align="left"><span class="style15"><span class="style19"><span class="style19"></span></span></span>
              <p>
                <label>
                  <input type="radio" name="If you were tiling in your home, would you purchase the punch for the project?" value="yes" id="If you were tiling in your home, would you purchase the punch for the project?_0" />
                  <span class="style18">                  Yes</span></label>
                <span class="style18"><br />
                <label>
                  <input type="radio" name="If you were tiling in your home, would you purchase the punch for the project?" value="no" id="If you were tiling in your home, would you purchase the punch for the project?_1" />
                  No</label>
                </span><br />
              </p>
            </div></td>
            <td><span class="style19"></span></td>
          </tr>
          <tr>
            <td colspan="3"><div align="left" class="style2">If you are a retailer would you be interested in stocking the punch?</div></td>
          </tr>
          <tr>
            <td><div align="left"><span class="style15"><span class="style19"><span class="style19"></span></span></span>
              <p>
                <label>
                  <input type="radio" name="If you are a retailer would you be interested in stocking the punch?" value="yes" id="If you are a retailer would you be interested in stocking the punch?_0" />
                  <span class="style18">Yes</span></label>
                <span class="style18"><br />
                <label>
                  <input type="radio" name="If you are a retailer would you be interested in stocking the punch?" value="no" id="If you are a retailer would you be interested in stocking the punch?_1" />
                  No</label>
                </span><br />
              </p>
            </div></td>
            <td><span class="style19"></span></td>
          </tr>
          <tr>
            <td><div align="center">
              <label for="label"></label>
            </div></td>
            <td><div align="center">
              <label for="label4"></label>
            </div></td>
          </tr>
          <tr>
            <td>
              <span class="style2">
              <label for="label"></label>              
              <label for="name">              </label>
              </span>              <span class="style21">
              <label for="name"></label>
              </span>              <label for="name"><div align="right" class="style2">Name:</div>
              </label>            </td>
            <td>
              <label for="label"></label>
              <div align="left">
                <input name="name" type="text" id="name" size="35" />
            </div></td>
          </tr>
          <tr>
            <td>
              <span class="style2">
              <label for="label"></label>              
              <label for="occupation">              </label>
              </span>              <span class="style21">
              <label for="occupation"></label>
              </span>              <label for="occupation"><div align="right" class="style2">Occupation:</div>
              </label>            </td>
            <td>
              <label for="label"></label>
              <div align="left">
                <input name="occupation" type="text" id="occupation" size="35" />
            </div></td>
          </tr>
          <tr>
            <td>
              <span class="style2">
              <label for="label"></label>              
              <label for="email">              </label>
              </span>              <span class="style21">
              <label for="email"></label>
              </span>              <label for="email"><div align="right" class="style2">Email:</div>
              </label>            </td>
            <td>
              <label for="label"></label>
              <div align="left">
                <input name="email" type="text" id="email" size="35" />
            </div></td>
          </tr>
          <tr>
            <td><div align="center" class="style2">
              <label for="label"></label>
              <label for="comments">
              <div align="right">Comments:</div>
              </label>
            </div></td>
            <td><div align="center">
              <label for="label"></label>
              <div align="left">
                <textarea name="comments" id="comments" cols="26" rows="5"></textarea>
              </div>
            </div></td>
          </tr>
          <tr>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td colspan="3" align="center" valign="middle"><span class="style2">Thank you for taking part in this survey!</span></td>
          </tr>
          <tr>
            <td align="center" valign="middle"> </td>
            <td> </td>
          </tr>
          <tr>
            <td colspan="3" align="center" valign="middle"><div align="center">
              <label for="submit"></label>
              <input type="submit" name="submit" id="submit" value="Send Survey!" />
            </div></td>
          </tr>
          <tr>
            <td colspan="2"> </td>
          </tr>
        </table>
      </form> 

Dont worry of course I have all the proper HTML stuff set up so that is not the issue

 

And this is my PHP script:

<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Contact Form";


function died($error) {
	// your error code can go here
	echo "We are very sorry, but there were error(s) found with the form your submitted. ";
	echo "These errors appear below.<br /><br />";
	echo $error."<br /><br />";
	echo "Please go back and fix these errors.<br /><br />";
	die();
}

// validation expected data exists
if
	(!isset($_POST['email'])) {
	died('We are sorry, but there appears to be a problem with the email your submitted.');		
}


$email_from = $_POST['email']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
  	died($error_message);
  }
$email_message = "Form details below.\n\n";

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}


$email_message .= "Email: ".clean_string($email_from)."\n";



  <textarea name='comments' rows='15' cols='40'>
  </textarea><br />




// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

<!-- include your own success html here -->
<style type="text/css">
body p {
font-family: Arial, Helvetica, sans-serif;
}
body p {
font-size: 24px;
}
body p {
text-align: center;
}
</style>


<p> </p>
<p> </p>
<p>Thank you for contacting Academia. </p>
<p>  </p>
<p>We will be in touch with you shortly</p>
<p> </p>
<p>Click here to return to Academia</p>
<?
}
?>

I also have another one available to use:

<?php

/* Subject and Email Variables */

$emailSubject = 'Crazy PHP Scripting!';
$webMaster = '[email protected]';

/* Gathering Data Variables */

$Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling projectField = $_POST['Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project'];
$Where would you expect to purchase THE TILE SPACER PUNCHField = $_POST['Where would you expect to purchase THE TILE SPACER PUNCH'];
$What price would you expect to purchase THE TILE SPACER PUNCHField = $_POST['What price would you expect to purchase THE TILE SPACER PUNCH'];
$If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punchField = $_POST['If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch'];
$If you were tiling in your home, would you purchase the punch for the projectField = $_POST['If you were tiling in your home, would you purchase the punch for the project'];
$If you are a retailer would you be interested in stocking the punchField = $_POST['If you are a retailer would you be interested in stocking the punch'];

$body = <<<EOD
<br><hr><br>
Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project: $Looking at the drawings and the function of the tool, would you consider it a useful tool during a tiling project
Where would you expect to purchase THE TILE SPACER PUNCH: $Where would you expect to purchase THE TILE SPACER PUNCH
What price would you expect to purchase THE TILE SPACER PUNCH: $What price would you expect to purchase THE TILE SPACER PUNCH
If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch: $If the punch was part of a DIY tiling kit, would you consider that kit above the kit not containing the punch
If you were tiling in your home, would you purchase the punch for the project: $If you were tiling in your home, would you purchase the punch for the project
If you are a retailer would you be interested in stocking the punch: $If you are a retailer would you be interested in stocking the punch
EOD;

$headers = "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

/* Results rendered as 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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The Tile Spacer Punch</title>
<style type="text/css">
<!--
body {
background-color: #1F2120;
background-image: url();
background-repeat: repeat;
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #F3EA5A;
}
a:active {
text-decoration: none;
color: #000000;
}
.style17 {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>
<table width="823" height="595" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="119" align="left" valign="top" bgcolor="#999999" scope="col"><img src="pictures for web/header1.jpg" width="823" height="119" border="0" usemap="#Map" /></td>
  </tr>
  
  <tr>
    <td height="18" align="center" valign="top" bgcolor="#999999"><img src="pictures for web/header_1.jpg" width="823" height="40" /></td>
  </tr>
  <tr>
    <td height="436" align="center" valign="middle" bgcolor="#999999"><p class="style17">Thank you for your input and submitting the form!</p>    </td>
  </tr>
</table>

<map name="Map" id="Map">
  <area shape="rect" coords="521,83,618,113" href="questionaire.html" />
<area shape="rect" coords="633,82,731,114" href="presentation.html" />
<area shape="rect" coords="740,82,807,112" href="contact.html" />
<area shape="rect" coords="451,82,507,110" href="index.html" />
</map>
<map name="Map2" id="Map2"><area shape="rect" coords="122,8,154,39" href="http://www.facebook.com/" />
<area shape="rect" coords="161,8,193,38" href="http://twitter.com/" />
</map></body>
</html>

EOD;
echo "$theResults";



?>

Which one should I use????

What changes do I have to make the script work?

The email I get from using the first script is:

 

Form details below.

Email: [email protected]

Link to comment
https://forums.phpfreaks.com/topic/244321-php-email-form-help-urgent-please/
Share on other sites

So for example how would I add that comments bit at the end?

So I should copy and paste it and which part of that php code should i refer to the html?

Please explain im not a php genie

What parts should I change for it?

Please show 1 or 2 examples

I would highly appreciate it so much

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.