Why is registration Email Confirmation code not being sent?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tutusaint
    New Member
    • Sep 2010
    • 18

    #1

    Why is registration Email Confirmation code not being sent?

    My registration confirmation code is not sending out emails.

    Please help.

    Code:
    <?php
    
    if (isset($_POST['Submit'])) {
    //$Bday  = date("dd-mm-yyyy");
    include "dbCon.php";
    
    $EmailAd = $_POST['EmailAd'];
    $Password = $_POST['Password'];
    $Name = $_POST['Name'];
    $Gender = $_POST['Gender'];
    $Bday = $_POST['Bday'];
    $Phone = $_POST['Phone'];
    $College = $_POST['College'];
    $Course = $_POST['Course'];
    $Yr = $_POST['Yr'];
    $UserType = $_POST['UserType'];
    
    
    /* Let's strip some slashes in case the user entered
    any escaped characters. */
    $EmailAd = stripslashes($EmailAd);
    $Password = stripslashes($Password);
    $Name = stripslashes($Name);
    $Gender = stripslashes($Gender);
    $Bday = stripslashes($Bday);
    $Phone = stripslashes($Phone);
    $College = stripslashes($College);
    $Course = stripslashes($Course);
    $Yr = stripslashes($Yr);
    $UserType = stripslashes($UserType);
    
    
    
    /* Let's do some checking and ensure that the user's email address or username
     does not exist in the database */
    
    $sql_email_check = mysql_query("SELECT emailad FROM user WHERE EmailAd='$EmailAd'");
    // $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
     
    $email_check = mysql_num_rows($sql_email_check);
    // $username_check = mysql_num_rows($sql_username_check);
     
     if(($email_check > 0)){
     	echo "Please fix the following errors: <br />";
     	if($email_check > 0){
     		echo "<strong>Your email address has already been used. Please use a different Email address!<br />";
     		unset($email_address);
     	
     	include 'index.php'; // Show the form again!
     	exit();  // exit the script so that we do not create this account!
    	}}
    	
    
    
    // table name 
    
    // Random confirmation code 
    $confirm_code=md5(uniqid(rand())); 
    
    
    $query = mysql_query("INSERT into temp_user (confirm_code, EmailAd, Password, Name, Gender, Bday, Phone, College, Course, Yr, UserType)
    					VALUES('$confirm_code', '$EmailAd', '$Password', '$Name', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType')");
    
    // $sql= "INSERT INTO user SET Regdate='$now',  expire='$exp'";
    
    if($result){
    	// ---------------- SEND MAIL FORM ----------------
    
    // send e-mail to ...
    $to=$emailad;
    
    // Your subject
    $subject="Your confirmation link here";
    
    // From
    //$header="from: mysite <alart@mysite.org>";
    
    // Your message
    mysql_query($query);
    $to = $emailad;
    $subject = 'Imostars e-mail address confirmation';
    $message = "
    <p>Hey! Thanks for being part of our alumni portal. Click below to confirm your e-mail address.</p>
    <p><a href='http://mysite.org/confirm.php?emailad=$emailad'>below</a></p>";
    				$headers = "ImoStars Alumni <alart@mysite.org>" . "\r\n" .
    							'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    				mail($to,$subject,$message,$headers);
    			?>
    <span style='color:green'>Congratulations, you've registered successfully! A confirmation e-mail has been sent to the address you entered.</span>
    
    
    }
    ?>
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Have you done any debugging on this whatsoever?

    Are there any errors?

    Comment

    • tutusaint
      New Member
      • Sep 2010
      • 18

      #3
      There are no errors.

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        Okay, have you tried debugging this at all?

        Comment

        • Niheel
          Recognized Expert Moderator Top Contributor
          • Jul 2005
          • 2433

          #5
          Your error is where you insert the code into the database and then check to see if the insert has been successful. This is causing the code to send an email to not execute.

          You assign the query to variable to ($query)
          Code:
          $query = mysql_query("INSERT into temp_user (confirm_code, EmailAd, Password, Name, Gender, Bday, Phone, College, Course, Yr, UserType)
                              VALUES('$confirm_code', '$EmailAd', '$Password', '$Name', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType')");
          But when you check to see if the query has been executed, you check for ($result)

          if($result){

          Change $result to $query or vice a versa

          Good Luck.
          niheel @ bytes

          Comment

          • Mohit Pilania
            New Member
            • May 2012
            • 1

            #6
            Originally posted by tutusaint
            There are no errors.

            Error is at the end of page.


            mail($to,$subje ct,$message,$he aders);
            }
            }
            ?>


            end your program here.

            Comment

            Working...