xmldevnewcastle
11-01-2007, 05:13 PM
trying to write an email script, been banging my head off the wall for hours, can anyone see anything wrong with this?
<?
$failure = 0;
error_reporting(0);
$errorlist = " ";
if(isset($_POST["Name"]) && $_POST["Name"] !="")
{
$name = $_POST["Name"];
}
else
{
$name = "";
$failure = 1;
$errorlist .= "A name is required.<br />";
}
if(isset($_POST["Subject"]) && $_POST["Subject"] !="")
{
$subject = $_POST["Subject"];
}
else
{
$subject = "";
$failure = 1;
$errorlist .= "Please provide a subject for this query so we can send it to the relevant department. <br />";
}
if(isset($_POST["Where"]) && $_POST["Where"] !="")
{
$where = $_POST["Where"];
}
else
{
$where = "";
$failure = 1;
$errorlist .= "Please state where you found us (yell.com, google etc).<br />";
}
if(isset($_POST["Email"]) & $_POST["Email"] !="")
{
$email = $_POST["Email"];
list($username,$domain) = split("@",$email);
}
else
{
$email = "";
}
if($domain == "")
{
$failure = 1;
$errorlist .= "Please provide a valid email address.<br />";
}
if(isset($_POST["Content"]) && $_POST["Content"] !="")
{
$content = $_POST["Content"];
}
else
{
$content = "";
$failure = 1;
$errorlist .= "Please provide some comments.<br />";
}
if($failure !=0)
{
if(isset($_POST["Posted"]))
{
echo("<p style='color:red;'>");
echo($errorlist);
echo("</p>");
}
?>
<form action="" method="post" class="contact">
<label for="name">Name:</label>
<input type="text" name="Name" id="name" value="<?=$name?>" />
<label for="email">E-mail:</label>
<input type="text" name="Email" id="email" value="<?=$email?>" />
<label for="subject">Subject:</label>
<input type="text" name="Subject" id="subject" value="<?=$subject?>" />
<label for="where">Where did you hear about us:</label>
<input type="text" name="Where" id="where" value="<?=$where?>" />
<label for="Content" style="margin-left:-120px;">Comments:</label>
<input type="hidden" name="Posted" ID="posted" value="1">
<textarea name="Content" ID="Content" style="width:450px; height:150px; margin-top:15px; _margin-top:-15px;">
<?=$content?>
</textarea>
<input type="submit" value="Send" style="width:70px; margin-top:15px; margin-left:252px;" />
</form>
<?
}
else
{
echo("<P>Thank you $name for your message. We will get back to you ASAP.</P>");
$msg = "<table border=0 style='border:1px solid #000000;'>";
$msg .= "<tr><td><img src='http://astra.streamlinenettrial.co.uk/images/header.jpg' style='width:750px; height:100px;' /></td></tr>";
$msg .= "<tr><td>";
$msg .= "<p><strong>From:</strong> $name</p>";
$msg .= "<p><strong>Subject:</strong> $subject</p>;";
$msg .= "<p><strong>Found us at:</strong> $where</p>;";
$msg .= "<p><strong>Comments:</strong><br /><br /> $content</p>;";
$msg .= "</td></tr>";
$msg .= "</table>";
$recipient = "ttpparker@talk21.com";
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1\r\n";
// Additional headers
$headers .= "From: TIM ParMEN <ttpparker@talk21.com>\r\n";
$headers .= "Reply-To: $email";
echo($subject);
echo($recipient);
echo($headers);
mail($recipient, $subject, $msg, $headers);
}
?>
<?
$failure = 0;
error_reporting(0);
$errorlist = " ";
if(isset($_POST["Name"]) && $_POST["Name"] !="")
{
$name = $_POST["Name"];
}
else
{
$name = "";
$failure = 1;
$errorlist .= "A name is required.<br />";
}
if(isset($_POST["Subject"]) && $_POST["Subject"] !="")
{
$subject = $_POST["Subject"];
}
else
{
$subject = "";
$failure = 1;
$errorlist .= "Please provide a subject for this query so we can send it to the relevant department. <br />";
}
if(isset($_POST["Where"]) && $_POST["Where"] !="")
{
$where = $_POST["Where"];
}
else
{
$where = "";
$failure = 1;
$errorlist .= "Please state where you found us (yell.com, google etc).<br />";
}
if(isset($_POST["Email"]) & $_POST["Email"] !="")
{
$email = $_POST["Email"];
list($username,$domain) = split("@",$email);
}
else
{
$email = "";
}
if($domain == "")
{
$failure = 1;
$errorlist .= "Please provide a valid email address.<br />";
}
if(isset($_POST["Content"]) && $_POST["Content"] !="")
{
$content = $_POST["Content"];
}
else
{
$content = "";
$failure = 1;
$errorlist .= "Please provide some comments.<br />";
}
if($failure !=0)
{
if(isset($_POST["Posted"]))
{
echo("<p style='color:red;'>");
echo($errorlist);
echo("</p>");
}
?>
<form action="" method="post" class="contact">
<label for="name">Name:</label>
<input type="text" name="Name" id="name" value="<?=$name?>" />
<label for="email">E-mail:</label>
<input type="text" name="Email" id="email" value="<?=$email?>" />
<label for="subject">Subject:</label>
<input type="text" name="Subject" id="subject" value="<?=$subject?>" />
<label for="where">Where did you hear about us:</label>
<input type="text" name="Where" id="where" value="<?=$where?>" />
<label for="Content" style="margin-left:-120px;">Comments:</label>
<input type="hidden" name="Posted" ID="posted" value="1">
<textarea name="Content" ID="Content" style="width:450px; height:150px; margin-top:15px; _margin-top:-15px;">
<?=$content?>
</textarea>
<input type="submit" value="Send" style="width:70px; margin-top:15px; margin-left:252px;" />
</form>
<?
}
else
{
echo("<P>Thank you $name for your message. We will get back to you ASAP.</P>");
$msg = "<table border=0 style='border:1px solid #000000;'>";
$msg .= "<tr><td><img src='http://astra.streamlinenettrial.co.uk/images/header.jpg' style='width:750px; height:100px;' /></td></tr>";
$msg .= "<tr><td>";
$msg .= "<p><strong>From:</strong> $name</p>";
$msg .= "<p><strong>Subject:</strong> $subject</p>;";
$msg .= "<p><strong>Found us at:</strong> $where</p>;";
$msg .= "<p><strong>Comments:</strong><br /><br /> $content</p>;";
$msg .= "</td></tr>";
$msg .= "</table>";
$recipient = "ttpparker@talk21.com";
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1\r\n";
// Additional headers
$headers .= "From: TIM ParMEN <ttpparker@talk21.com>\r\n";
$headers .= "Reply-To: $email";
echo($subject);
echo($recipient);
echo($headers);
mail($recipient, $subject, $msg, $headers);
}
?>