I cant send a confirmation email with XAMPP, i think it has the PHP 5.3.0. i have tried to read about it in other forums, but there answers didn't work for me. I can start with the php.ini
php.ini
Code:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"
and the error message is:
Code:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\Skynet\registrationcheck.php on line 37
here is the registrationcheck.php
Code:
<?php
require('connecttodatabase.php'); //connect to database
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repeat_password = strip_tags($_POST['repeat-password']);
//test to see if name only contains letters
if(!preg_match(("[^A-Za-z ]"),$name))
{
//remember to make one for "too long name"
//check if email in use
$checkemailcommand="SELECT * FROM users WHERE email = '$email'";
$checkemailresult = mysql_query($checkemailcommand);
$num=mysql_num_rows($checkemailresult);
if($num==0){
//if passwords match up (should do it for email to but it ist done)
if($password==$repeat_password){
//we generate random code for confirmation email
$confirm_code=md5(uniqid(rand()));
//then we insert their info in a temporary database
$insertinfocommand="INSERT INTO temp SET code='$confirm_code', name = '$name', email = '$email', password = '$password'";
$insertinforesult=mysql_query($insertinfocommand);
//if the info is succsesfully entered temp, we are going to send an email
if($insertinforesult){
$message = "Your Confirmation link: \r\n http://redboook.netii.net/confirmation.php?passkey=$confirm_code"; //link to the confirmation page where the var passkey is the same as their code
$sendmail = mail("$email","Redbook confirmation code","$message");
echo "confirmation link have been sent to your email ".$email;
}else{
echo "couldn't find your email in our database";
}
}else{
echo "password doesn't match";
//header("Location:passworddoesntmatch.html")
}
}else{
echo "email in use";
//header("Location:alreadyregistered.html");
}
}else{
echo "invalid name";
//header("Location:invalidname.html");
}
?>
if you need to see the confirmation.php here is it
Code:
<?php
require('connecttodatabase.php'); //connect to database
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repeat_password = strip_tags($_POST['repeat-password']);
//test to see if name only contains letters
if(!preg_match(("[^A-Za-z ]"),$name))
{
//remember to make one for "too long name"
//check if email in use
$checkemailcommand="SELECT * FROM users WHERE email = '$email'";
$checkemailresult = mysql_query($checkemailcommand);
$num=mysql_num_rows($checkemailresult);
if($num==0){
//if passwords match up (should do it for email to but it ist done)
if($password==$repeat_password){
//we generate random code for confirmation email
$confirm_code=md5(uniqid(rand()));
//then we insert their info in a temporary database
$insertinfocommand="INSERT INTO temp SET code='$confirm_code', name = '$name', email = '$email', password = '$password'";
$insertinforesult=mysql_query($insertinfocommand);
//if the info is succsesfully entered temp, we are going to send an email
if($insertinforesult){
$message = "Your Confirmation link: \r\n http://redboook.netii.net/confirmation.php?passkey=$confirm_code"; //link to the confirmation page where the var passkey is the same as their code
$sendmail = mail("$email","Redbook confirmation code","$message");
echo "confirmation link have been sent to your email ".$email;
}else{
echo "couldn't find your email in our database";
}
}else{
echo "password doesn't match";
//header("Location:passworddoesntmatch.html")
}
}else{
echo "email in use";
//header("Location:alreadyregistered.html");
}
}else{
echo "invalid name";
//header("Location:invalidname.html");
}
?>
i will appreciate anykind of respond. and i can also tell you that i ave checked the database and everything is fine. when i upload the files to 000webhost everything works fine, but for several reasons i like to use XAMPP localhost.
if there is some information you want to know about the script or something like that I can post that up too. if you didn't understand something just let me know and I'll try to explain it.