For some reason every time that I press the send button it sends the email but it does not post the information.
Please help. Thank you.
Code:
<?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = '[email protected]';//replace with your email
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
if (!isset($_POST["submit"])) { ?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
To: <input type="text" name="to_email"><br>
From: <input type="text" name="from_email"><br>
Subject: <input type="text" name="subject"><br>
Message: <textarea rows="10" cols="20" name="message"></textarea><br>
<input type="submit" name="submit" value="Send Email">
</form>
<?php
if (isset($_POST["to_email"])) {
$to_email = $_POST["to_email"];
$from_email = $_POST["from_email"];
$subject = $_POST["subject"];
$body = $_POST["message"];
if ( mail($to_email, $subject, $body, $headers)) {
echo("Email successfully sent to $to_email...");
} else {
echo("Email sending failed...");
}
}
}
?>