Jump to content

E-mail not sent ?


jd2007

Recommended Posts

i installed MailEnable Standard and below is my code

 

registration.php

<?php

/*Use of Sessions*/
if(!session_id())
session_start();

header("Cache-control: private"); //avoid an IE6 bug (keep this line on top of the page)

//function validateEmail($email)
  //{
   // return ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$", $email);
  //}



if (isset($_POST['nickname']) && isset($_POST['password']) && isset($_POST['cpass']) && isset($_POST['email'])) {
    if (isset($_POST['password']) == isset($_POST['cpass'])) {
        if (ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",($_POST['email']))) {
           /*Connection to database logindb using your login name and password*/
           $db=mysql_connect('localhost','root') or die(mysql_error());
            mysql_select_db('Vote');
            
            /*additional data checking and striping*/
            $_POST['nickname']=mysql_real_escape_string(strip_tags(trim($_POST['login'])));
            $_POST['cpass']=mysql_real_escape_string(strip_tags(trim($_POST['cpass'])));
            
            mysql_query("INSERT INTO Users SET nickname='{$_POST['nickname']}',cpass='{$_POST['cpass']}'",$db);
            
            if(mysql_affected_rows() > 0)
             {
     $_SESSION['nickname'] = $_POST['nickname'];
     $to = $_POST['email'];
              
             $subject = 'Voting User Confirmation';
              
             
             $headers = "From: [email protected] ";
             $headers .= "MIME-Version: 1.0rn "; 
             $headers.= "Content-type: text/html; charset=iso-8859-1rn";;
             
             
             
             $message="
             
             <b>You are one step away to cast your vote.<br>
             Click the link below to confirm your registration.<br><br>
             <a href='login.php'>Confirm !</a>  
             </b>";

          
              $mail_sent=mail( $to, $subject, $message, $headers );
           
          echo $mail_sent ? "A confirmation mail has been sent to your e-mail address. Please click the link which is provided." : "We're sorry, sending confirmation mail failed. ";
             }
             
             else
             {
     $nickname= 'Please choose another nickname.';
     echo $nickname;
     exit;
             }

            } 
             else {
             echo "Please enter a valid e-mail.";
             //echo "<style></style>";
             //echo "<img src='' class=''>";
               echo "<form method='post' action='registration.php'>
              Nickname: <input type='text' name='nickname'>
                Password: <input type='password' name='password'>
              Confirm Password: <input type='password' name='cpass'>
             E-mail: <input type='text' name='email'>
               <input type='submit' value='Register'>
              </form>";
              exit;
             }
             
             
    } else if (isset($_POST['password']) != isset($_POST['cpass'])) {
        echo "Passwords does not match.";
        echo "<style></style>";
             echo "<img src='' class=''>";
               echo "<form method='post' action='registration.php'>
              Nickname: <input type='text' name='nickname'>
                Password: <input type='password' name='password'>
              Confirm Password: <input type='password' name='cpass'>
             E-mail: <input type='text' name='email'>
               <input type='submit' Register'>
              </form>"; 
              exit;
       }
       else {}
} else if (!isset($_POST['nickname']) || !isset($_POST['password']) || !isset($_POST['cpass']) ||    !isset($_POST['email'])) {
   echo "Please fill in all fields.";
   
             
               echo "<form method='post' action='registration.php'>
              Nickname: <input type='text' name='nickname'>
                Password: <input type='password' name='password'>
              Confirm Password: <input type='password' name='cpass'>
             E-mail: <input type='text' name='email'>
               <input type='submit' value='Register'>
              </form>";
               exit;
}
else {}
?>

 

register.php

<?php
if(!session_id())
session_start();

header("Cache-control: private"); //avoid an IE6 bug (keep this line on top of the page)
//echo "<style></style>";
//echo "<img src='' class=''>";
echo "<form method='post' action='registration.php'>
      Nickname: <input type='text' name='nickname'>
      Password: <input type='password' name='password'>
      Confirm Password: <input type='password' name='cpass'>
      E-mail: <input type='text' name='email'>
      <input type='submit' value='Register'>
      </form>";
?>

 

i got this output after filling up register.php:

A confirmation mail has been sent to your e-mail address. Please click the link which is provided.

 

i entered my e-mail address but when i checked my mail, i did not recieve anything...why ?

 

Link to comment
https://forums.phpfreaks.com/topic/59945-e-mail-not-sent/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.