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
Share on other sites

i get this :

 

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\AppServ\www\Voting\registration.php on line 51

We're sorry, sending confirmation mail failed.

Link to comment
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 = example@example.co.uk

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.