Jump to content

Help please


Noskiw

Recommended Posts

Can anyone make it so that this successfully sends email from a localhost server.

 

<?php

$submit = $_POST['submit'];

$id = $_GET['id'];

$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$email = addslashes(strip_tags($_POST['email']));
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");

if($submit){
    if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){        
        if($password == $verifypassword){
            if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){
                echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters";
            }else{
                if(strlen($password)>25||strlen($password)<6){
                    echo "Password must be <b>between</b> 6 and 25 characters!";
                }else{
                    $password = md5($password);
                    $verifypassword = md5($verifypassword);
                    
                    $random = rand(23456789,98765432);

                    $sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')";
                    $res = mysql_query($sql) or die(mysql_error());
                    
                    $lastid = mysql_insert_id();
                    
                    
                    $to = $email;
                    $subject = "Activate your account!";
                    $body = "
                    
                    Hello $firstname $lastname,\n\n
                    
                    You need to activate your account with the link below...
                    
                    http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n
                    
                    Thanks!
                    
                    ";
                    $headers = "From: [email protected]";
                    
                    mail($to, $subject, $body, $headers);
                    
                    echo "Success! Check your email to activate your account!";
                    
                    }
                }
            }
        }else{
            echo "Passwords <b>Do Not Match</b>!";
        }
     }else{
        echo "Please fill in <b>all</b> fields!";
     }


?>

<form action="index.php?p=reg" method="POST"> 
    <table>
        <h1>Register</h1>
        <tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr>
        <tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr>
        <tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr>
        <tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr>
        <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>
        <tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr>
        <tr><td><input type="submit" name="submit" value="Register" /></tr></td>
    </table>
</form>

 

Because it always says that the email has been sent... Yet it never arrives... -.-'

Link to comment
https://forums.phpfreaks.com/topic/203920-help-please/
Share on other sites

I have a different problem now -.-'

 

THis is my code now

 

<?php

$submit = $_POST['submit'];

$id = $_GET['id'];

$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$email = addslashes(strip_tags($_POST['email']));
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");

if($submit){
    if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){        
        if($password == $verifypassword){
            if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){
                echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters";
            }else{
                if(strlen($password)>25||strlen($password)<6){
                    echo "Password must be <b>between</b> 6 and 25 characters!";
                }else{
                    $password = md5($password);
                    $verifypassword = md5($verifypassword);
                    
                    $random = rand(23456789,98765432);

                    $sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')";
                    $res = mysql_query($sql) or die(mysql_error());
                    
                    $lastid = mysql_insert_id();
                    
                    
                    $to = $_POST['email'];
                    $subject = "Activate your account!";
                    $body = "
                    
                    Hello $firstname $lastname,\n\n
                    
                    You need to activate your account with the link below...
                    
                    http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n
                    
                    Thanks!
                    
                    ";
                    
                    $headers = "From: [email protected]";                                        
                    
                    mail($to, $subject, $body, $headers);
                    
                    echo "Success! Check your email to activate your account!";
                    
                    }
                }
            }
        }else{
            echo "Passwords <b>Do Not Match</b>!";
        }
     }else{
        echo "Please fill in <b>all</b> fields!";
     }


?>

<form action="index.php?p=reg" method="POST"> 
    <table>
        <h1>Register</h1>
        <tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr>
        <tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr>
        <tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr>
        <tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr>
        <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>
        <tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr>
        <tr><td><input type="submit" name="submit" value="Register" /></tr></td>
    </table>
</form>

 

This is my php.ini mail function settings

 

[mail function]
; For Win32 only.
SMTP = smtp.googlemail.com
smtp_port = 465

; For Win32 only.
;sendmail_from = [email protected]

 

And this is my error

 

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:\xampp\htdocs\projects\p_web\include\reg.php on line 51

 

-.-' That is insanely frustrating...

Link to comment
https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068169
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.