Forum Moderators: coopster

Message Too Old, No Replies

emailing in registration page got problem

         

lindaonline15

2:46 pm on Aug 28, 2008 (gmt 0)

10+ Year Member



hi... this is a registration page. when I create a user in it, it will register, but got problem with sending email part.
this is what gives after I register:

You have successfully Registered
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:\wamp\www\register.php on line 65
Your information has been mailed to your email address.

this is the code:
<html>
<head>
<title>Register</title>
<head>

<body>

<?PHP

//Connect to database

mysql_connect("localhost", "admin", "admin") or die(mysql_error());
mysql_select_db("ueros_db") or die(mysql_error());


$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$emailedpass = $_POST['password'];

// lets check to see if the username already exists

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
unset($username);
include 'register.html';
exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";

// mail user their information

$mysite = ‘www.example.com’;
$webmaster = ‘adib’;
$myemail = "email@example.com";

$subject = "You have successfully registered at $mysite...";
$message = "Dear $name, you are now registered at our web site.
To login, simply go to our web page and enter in the following details in the login form:
Username: $username
Password: $emailedpass

Please print this information out and store it for future reference.

Thanks,
$webmaster";

mail($email, $subject, $message, "From: $mysite <$myemail>\nX-Mailer:PHP/" . phpversion());

echo "Your information has been mailed to your email address.";

?>

</body>
</html>

anyone can help me with this?
thanks

[edited by: eelixduppy at 4:40 pm (utc) on Aug. 28, 2008]
[edit reason] exemplified [/edit]

dreamcatcher

9:03 am on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you testing on localhost or a production server? If local server, try it on a production server. If you are on a production server, the error message is giving you a clue what you need to do:

verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

dc

andrewsmd

12:43 pm on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't really know a lot about smtp but I have script that automatically generates a password for a user and e-mails it. I can post it if you want. I can't guarantee it will work, however, because our php servers may be different. Just let me know.