- Impact
- 16
This script allows people to send me email. But it always get error like this:
and i dont even know what it means.
here is the code:
Code:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/******/public_html/mail.php:2) in /home/******/public_html/mail.php on line 4
here is the code:
PHP:
<?php
if ($_POST['action'] == "go") {
session_start();
$name = $_POST['name'];
$email = $_POST['email'];
$content = $_POST['content'];
if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) $alert = "You have entered an invalid email address.";
if ($name == "" OR $email == "" OR $content == "") $alert = "To send a message, please complete all 3 fields.";
if ($_SESSION['mail_count'] >= "3") $alert = "Only 3 messages can be sent per session.";
if (!$alert) {
if (!isset($_SESSION['mail_count'])) $_SESSION['mail_count'] = 0;
$_SESSION['mail_count']++;
$message .= "Name as follows:\n\n";
$message .= "$name\n\n";
$message .= "Email address as follows:\n\n";
$message .= "$email\n\n";
$message .= "Message as follows:\n\n";
$message .= "$content\n\n";
mail("[email protected]", "yourdomain.com Message" , "$message", "From: Website <>");
$name = "";
$email = "";
$content = "";
$alert = "Your message has been sent.";
}
}
?>
<html>
<head>
</head>
<body>
<table align=center cellspacing="0" cellpadding="5" border="1" style="height: 450px; width: 500px; margin-top: 50; border-style:inset;">
<tr><td align="center"><form method=post action="mail.php"><br>
Send me a message<br><br>
your name<br><input type=text style="width: 330px;" name=name value="<?=$name?>" maxlength=50><br><br>
your email address<br><input type=text style="width: 330px;" name=email value="<?=$email?>" maxlength=50><br><br>
your message<br><textarea name="content" rows="6" cols="40"><?=$content?></textarea>
<br><br>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="action" value="go">
</form></td></tr>
</table>
<?php
if ($alert) {
echo "<script type='text/javascript'>
<!--
alert ('$alert');
//-->
</script>";
}
?>
</body></html>













