Associate
I am setting up a registration form so that people can create an account on my web site. When they click register an activation code is meant to send to the users email so that they can activate there account then log into there member section. However, the account gets set up but the activation does not send and I get this error message on my localhost (Shown below)
I am not sure if its the fact I am using wamp server to test my files but any way here is the code I use and I am guessing it is something to do with the ini_set(); function
$headers = "From: [email protected]";
$server = "mail.gridhost.co.uk";
ini_set ("SMTP", "$server");
I am not sure if its the fact I am using wamp server to test my files but any way here is the code I use and I am guessing it is something to do with the ini_set(); function
$headers = "From: [email protected]";
$server = "mail.gridhost.co.uk";
ini_set ("SMTP", "$server");
PHP:
<?php
$submit = @$_POST['submit'];
// Forum Data
$fullname = strip_tags(@$_POST['fullname']);
$username = strtolower(strip_tags(@$_POST['username']));
$email = strip_tags(@$_POST['email']);
$password = strip_tags(@$_POST['password']);
$repeatpassword = strip_tags(@$_POST['repeatpassword']);
$date = date('Y-m-d');
if ($submit)
{
// Open our database
$connect = mysql_connect("localhost", "root", "password123");
mysql_select_db("phplogin");// Select Database
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);
if($count!=0)
{
die("Username already taken!");
}
// Check for existance
if ($fullname&&$username&&$password&&$repeatpassword)
{
if ($password==$repeatpassword)
{
// Check char length of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo "Length of Username or Fullname too long!";
}
else {
//Check Password length
if (strlen($password)>25||strlen($repeatpassword)<6)
{
echo "Password must be between 6 to 25 characters!";
}
else
{
// Register User
// Repeat Password
$password=md5($password);
$repeatpassword=md5($repeatpassword);
// Generate random number for activation.
$random = rand(23456789,98765432);
$queryreg = mysql_query("INSERT INTO users VALUES ('', '$fullname', '$username', '$email', '$password', '$date', '$random', '0')");
$lastid = mysql_insert_id();
// Send activation email
$to = $email;
$subject = "Activate your Typer account!";
$headers = "From: [email protected]";
$server = "mail.gridhost.co.uk";
ini_set ("SMTP", "$server");
$body ="
Hello $fullname, \n\n
You need to activate your account with the link below:
http://localhost/typer.me/activate.php?id=$lastid&code=$random \n\n
Thanks!
Typer.me
";
// Function to send email
mail($to, $subject, $body, $headers);
die ("You have been registered! Check your email to activate your account.");
}
}
}
else
echo "Your passwords do not match!";
}
else
echo "Please fill in <b>ALL</b> fields!";
}
?>
Last edited: