Putting together a simple email responce form.... I think the code is pretty easy and for some reason it wont work.... please help....
CODE
<?php
if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$mailing = $_POST['mailing'];
if($name == '' or $email == '' or $comments == '') {
$err = true;
$msg = 'Please complete your name, email address and comments to submit the form.';
} else {
$mailmsg = 'The following email has been sent from the contact form:' . "\n\n";
$mailmsg.= 'Name: ' . $name . "\n";
$mailmsg.= 'Email: ' . $email . "\n";
$mailmsg.= 'Comments: ' . $comments . "\n";
if($mailing == 'true') {
$mailmsg.= 'I would like to be added to the mailing list';
}
if (eregi("\r",$email) || eregi("\n",$email)){
die ("spam!");
} else {
if(mail('jimwinfield@cox.net','Contact Form', $mailmsg, "From: noreply@example.com")) {
header("Location: thankyou.html");
}
}
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Contact Form</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if($err == true) {
echo '<p class="error">'. $msg . '</p>';
}
?>
<form id="form1" method="post" action="contact.php">
<div>
<label for="name">Name</label>
<input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" />
</div>
<div>
<label for="email">Email address</label>
<input name="email" type="text" class="text" id="email" value="<?php echo $email; ?>" />
</div>
<div>
<label for="comments">Comments</label>
<textarea name="comments" cols="30" rows="6" class="text" id="comments"><?php echo $comments; ?></textarea>
</div>
<div>
<label for="mailing">Add me to your mailing list</label> <input type="checkbox" name="mailing" value="true" id="mailing" />
</div>
<div>
<input name="Submit" type="submit" class="btn" value="Submit" />
</div>
</form>
</body>
</html>
if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$mailing = $_POST['mailing'];
if($name == '' or $email == '' or $comments == '') {
$err = true;
$msg = 'Please complete your name, email address and comments to submit the form.';
} else {
$mailmsg = 'The following email has been sent from the contact form:' . "\n\n";
$mailmsg.= 'Name: ' . $name . "\n";
$mailmsg.= 'Email: ' . $email . "\n";
$mailmsg.= 'Comments: ' . $comments . "\n";
if($mailing == 'true') {
$mailmsg.= 'I would like to be added to the mailing list';
}
if (eregi("\r",$email) || eregi("\n",$email)){
die ("spam!");
} else {
if(mail('jimwinfield@cox.net','Contact Form', $mailmsg, "From: noreply@example.com")) {
header("Location: thankyou.html");
}
}
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Contact Form</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if($err == true) {
echo '<p class="error">'. $msg . '</p>';
}
?>
<form id="form1" method="post" action="contact.php">
<div>
<label for="name">Name</label>
<input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" />
</div>
<div>
<label for="email">Email address</label>
<input name="email" type="text" class="text" id="email" value="<?php echo $email; ?>" />
</div>
<div>
<label for="comments">Comments</label>
<textarea name="comments" cols="30" rows="6" class="text" id="comments"><?php echo $comments; ?></textarea>
</div>
<div>
<label for="mailing">Add me to your mailing list</label> <input type="checkbox" name="mailing" value="true" id="mailing" />
</div>
<div>
<input name="Submit" type="submit" class="btn" value="Submit" />
</div>
</form>
</body>
</html>
I tries testing the code My Website
Upon "submit"
it spits out this "Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The mail() command is not allowed. in /www/vndv.com/j/i/m/jimbeingjim/htdocs/contact.php on line 22"
What should I do
Thanks Jim
