Jump to content

php code help ?


jd2007

Recommended Posts

<?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 = isset($_POST['email']);
              
             $subject = 'Voting User Confirmation';
              
             
              
             $headers = "MIME-Version: 1.0rn"; 
             $headers.= "Content-type: text/html; charset=iso-8859-1rn";
             
             
             
             $message="
             <img>
             <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 {}
?>

 

what's wrong in the above code ... i get this error:

 

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\AppServ\www\Voting\registration.php on line 51

Link to comment
https://forums.phpfreaks.com/topic/59932-php-code-help/
Share on other sites

You have to have mail server installed on your testingf server, if you do, then go to your PHP.ini file and search for the bit in it and set it to this:

 

[mail function]

; For Win32 only.

SMTP = localhost

smtp_port = 25

 

; For Win32 only.

;sendmail_from = [email protected]

Link to comment
https://forums.phpfreaks.com/topic/59932-php-code-help/#findComment-298050
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.