Question:
Another PHP/Mysql error need help again please?
Jo
2010-03-24 15:25:47 UTC
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\xampp\htdocs\registernext.php on line 50

heres the code again
include('connectionfile.php');


$test_username = $_POST='username';
$test_password = $_POST='password';


if(!eregi("[^A-Za-z0-9]", $test_username) && !eregi("[^A-Za-z0-9]", $test_password))
{
$name_collision = "SELECT * FROM users WHERE username = '$_POST[username]'";
$email_collision = "SELECT * FROM users WHERE email = '$_POST[email]'";

//name result will do the action name collision which is select all
//from users where the username is equal to the person's typed username.

$name_result = mysql_query($name_collision);
$email_result = mysql_query($email_collision);

//name rows will get the number of rows in name result. it will check
//if there is any rows with the name collision data.

$name_rows = mysql_num_rows($name_result);
$email_rows = mysql_num_rows($email_result);

//checks if email and username isn't in the database
if($name_rows == 0 && $email_rows == 0)
{
//if the post variable pass is exactly equal to the confirm pass
//if the email is exactly equal to the email field.
if($_POST['password'] == $_POST['password2'] && $_POST['email'] == $_POST['email2'])
{
$confirmation_code = md5(uniqid(rand()));
//strip out all the tags so that hackers can't hack
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$email = strip_tags($_POST['email']);
// insert into the temp and set the field code into a random unique letters and make
//username = to the username and the email.
$sql = "INSERT INTO temp SET code = '$confirmation_code', username='$name', password = '$password', email = '$email'";
$insert_result = mysql_query($sql);

if($insert_result)
{
//send a message to the users email entered.
// dot after the message means add-on to the message string
$message = "Your confirmation link \r\n";
$message.= "Click on this link to activate your account: \r\n";
$message.= "localhost/Confirmation.php?passkey='$confirmation_code'";
$sent_mail = mail("$email","Registration Confirmation","$message", "From: Pasantorxstudios@live.co.uk");

if($sent_mail)
{
echo 'A confirmation email has been sent to your email address.';
}
else
{
die('Confirmation email not sent');
}
}
else
{
die('Account not added to the database!');
}
}
else
{
die("Email and or password confirms doesn't match");
}
}
// if it is it will die and print out on the screen.
else
{
die('Email or username is allready in use!: ' . mysql_error());
}
}
else
{
die('Username and password can only contain letters and password, try again.' . mysql_error());
}






?>
Three answers:
J.J.'s Advice / Avis de J.J.
2010-03-24 15:33:19 UTC
Now you've done the same thing again. You didn't really read the error message. It's telling you that you haven't set up an SMTP server in your php.ini settings file. You have to do that before PHP will be able to send e-mails. The basic setting for it is to try and use a mail server hosted on the local machine, but on a development XAMPP server such as yours, this won't work. You'll have to either actually set up a mail server on your computer, or use a free one like Gmail.
nibinaearr
2010-03-24 16:12:57 UTC
It means you haven't set up SMTP in your php.ini file. It is usually located in c:\php\php.ini where c:\php is your installation directory. I personally don't worry about this one. I've tried to set up an smtp server in the past but failed. I usually leave the error, check that the syntax of the email I'm trying to send looks right, and then verify it'll send the email once it's uploaded to the server. There are free smtp servers you could use instead, for example "free smtp server" which is very simple and could sort your problem out.
anonymous
2016-04-14 10:34:19 UTC
Normallly that is caused by selecting a non-existent field in the table. Insure the field "Key" exists in table pptable. Check Username while you are there.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...