Hi there. I copied this contact form script directly from another site which I created (albeit on a different server) and now it isn’t sending the mail. Can anyone see what the problem may be? It’s got me stumped and I don’t really want to have to start from scratch as it was a good script. (plus it took me and the posters on this forum ages to get working!)
[code=php]<?php
if ($_SERVER[‘REQUEST_METHOD’] != ‘POST’){
$me = $_SERVER[‘PHP_SELF’];
?>
<form name=”form1″ action=”contact.php” method=”post”>
<div class=”group”>
<div class=”row”>
<span class=”label”>Full Name*</span><span class=”formw”><input type=”text” size=”25″ name=”name” /></span>
</div>
<div class=”row”>
<span class=”label”>Company*</span><span class=”formw”><input type=”text” size=”25″ name=”company” /></span>
</div>
<div class=”row”>
<span class=”label”>Position</span><span class=”formw”><input type=”text” size=”25″ name=”position” /></span>
</div>
<div class=”row”>
<span class=”label”>Email*</span><span class=”formw”><input type=”text” size=”25″ name=”email” /></span>
</div>
<div class=”row”>
<span class=”label”>Contact Number*</span><span class=”formw”><input type=”text” size=”25″ name=”number” /></span>
</div>
<div class=”row”>
<span class=”label”>Comments, feedback or nature of enquiry*</span><span class=”formw”>
<textarea cols=”25″ rows=”8″ name=”comments”></textarea></span>
</div>
<div class=”row”>
<span class=”label”>Tick this box if you would like to join the Skills Exchange mailing list</span><span class=”formw”><input type=”checkbox” size=”25″ name=”list” /></span>
</div>
<div class=”row”>
<span class=”formw”><input type=”submit” name=”Submit” value=”Send”></span>
</div>
<div class=”spacer”>
</div>
</div>
</form>
<p>* marks required fields</p>
<?php
} else {
error_reporting(0);
$errors = array();
$page = $_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’];
if (!session_is_registered(“SESSION”)){
$errors[] = “Invalid form submission”;
}
if (!$_POST[‘name’])
$errors[] = “Name is required”;
if (!$_POST[’email’])
$errors[] = “Email Address is required”;
if (!$_POST[‘company’])
$errors[] = “Company is required”;
if (!$_POST[‘number’])
$errors[] = “Contact number is required”;
if (!$_POST[‘comments’])
$errors[] = “Message body is required”;
if (count($errors)>0){
echo “<h2>ERROR:</h2>n”;
foreach($errors as $err)
echo “<p>$err</p>n”;
} else {
$to = “[email protected]”;
$name = stripslashes($_POST[‘name’]);
$email = stripslashes($_POST[’email’]);
$comments = stripslashes($_POST[‘comments’]);
$company = stripslashes($_POST[‘company’]);
$position = stripslashes($_POST[‘position’]);
$number = stripslashes($_POST[‘number’]);
$list = stripslashes($_POST[‘list’]);
$msg = ”
<p><b>Name:</b> t$name<br />n
<b>Company:</b> t$company<br />n
<b>Position:</b> t$position<br />n
<b>Email:</b> t$email<br />n
<b>Contact number:</b> t$number<br />n
<b>Comments:</b> t$comments<br />n
<b>Mailing List:</b> t$list<br /></p>n”;
$msg1 = “<html>n
<head>n
<title>Contact/Feedback form</title>n
</head>n
<body>n
<h3>Contact/Feedback form</h3>n
$msg
</body>n
</html>n”;
$subject = “Online conatct form”;
$headers = ‘MIME-Version: 1.0’ . “rn”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “rn”;
if (mail($to, $subject, $msg1, $headers, ‘[email protected]’))
echo (“<h3>Your message has been sent</h3>n
<p>We will endeavour to reply to you as soon as possible</p>
$msg”);
else
echo “<h3>Message failed to send</h3>n
<p>Please try again later or contact Hamishn
by using one of the other methods of contact listedn
on this page.</p>”;
}
}
?>