So i set up an email activation script (i am using XAMPP) and when i test the email function using email@localhost it works fine but when i try with [email protected] i doesn't send the activation code
Heres the scripts:
register.php:
<html>
<body>
<h1>Sign up</h1>
<form action="verify.php" method="post" name="register">
Username: <br><input type="text" name="fullname" /> <br>
Email: <br><input type="text" name="email" /> <br>
Password: <br><input type="password" name="password" /> <br>
Repeat password:<br> <input type="password" name="repassword" /> <br>
<input type="hidden" name="form_submitted" value="1"/>
<input type="submit" />
</form>
</body>
</html>
verify.php
<?php
$b_email = $_POST['b_email'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
if ($_POST['form_submitted'] == '1') {
$activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
$sql="INSERT INTO users (fullname, password, email, activationkey, status)
VALUES
('$_POST[fullname]', '$_POST[password]', '$_POST','$activationKey', 'verify')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration.";
##Send activation Email
$to = $_POST['email'];
$subject = " YOURWEBSITE.com Registration";
$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\http://localhost/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ YOURWEBSITE.com Team";
$headers = 'From: testuser1@localhost' . "\r\n" .
'Reply-To: testuser1@localhost' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} else{
##User isn't registering, check verify code and change activation code to null, status to activated on success
$queryString = $_SERVER['QUERY_STRING'];
$query = "SELECT * FROM users";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
if ($queryString == $row["activationkey"]){
echo "Congratulations!" . $row["username"] . " is now the proud new owner of an YOURWEBSITE.com account.";
$sql="UPDATE users SET activationkey = '', status='activated' WHERE (id = $row[id])";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
}
}
}
?>
Thanks!
The passwords in the database are md5 encrypted.
and yes i am using mercury mail, perhaps its not set up right?
sorry its not md5 encrypted
(i was thinking of another script)
Heres the scripts:
register.php:
<html>
<body>
<h1>Sign up</h1>
<form action="verify.php" method="post" name="register">
Username: <br><input type="text" name="fullname" /> <br>
Email: <br><input type="text" name="email" /> <br>
Password: <br><input type="password" name="password" /> <br>
Repeat password:<br> <input type="password" name="repassword" /> <br>
<input type="hidden" name="form_submitted" value="1"/>
<input type="submit" />
</form>
</body>
</html>
verify.php
<?php
$b_email = $_POST['b_email'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
if ($_POST['form_submitted'] == '1') {
$activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
$sql="INSERT INTO users (fullname, password, email, activationkey, status)
VALUES
('$_POST[fullname]', '$_POST[password]', '$_POST','$activationKey', 'verify')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration.";
##Send activation Email
$to = $_POST['email'];
$subject = " YOURWEBSITE.com Registration";
$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\http://localhost/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ YOURWEBSITE.com Team";
$headers = 'From: testuser1@localhost' . "\r\n" .
'Reply-To: testuser1@localhost' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} else{
##User isn't registering, check verify code and change activation code to null, status to activated on success
$queryString = $_SERVER['QUERY_STRING'];
$query = "SELECT * FROM users";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
if ($queryString == $row["activationkey"]){
echo "Congratulations!" . $row["username"] . " is now the proud new owner of an YOURWEBSITE.com account.";
$sql="UPDATE users SET activationkey = '', status='activated' WHERE (id = $row[id])";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
}
}
}
?>
Thanks!
The passwords in the database are md5 encrypted.
and yes i am using mercury mail, perhaps its not set up right?
sorry its not md5 encrypted
(i was thinking of another script)