Hello again I have a problem. I was following tutorials and I came up with some code to register for the game witch I have no problem doing, but it is sending email conformation. Here is my code. The problem is I dont get the email and when I submit the form it goes to the "Thank You" page. Why is that??
<?php
include('config.php');
//test to see if username is alphanumeric
$testname=$_POST[username];
if(!eregi("([^A-Za-z0-9])",$testname)){
//test for duplicate names
$query="SELECT * FROM users WHERE username = '$_POST[username]'";
$result=mysql_query($query);
$num = mysql_num_rows($result);
if($num == 0){
//test for duplicate email
$query2="SELECT * FROM users WHERE email = '$_POST[email]'";
$result2=mysql_query($query2);
$num2 = mysql_num_rows($result2);
if($num2==0){
//if emails and passwords match up
if(($_POST['pass']==$_POST['pass2'])&&($_POST['email']==$_POST['email2'])){
// Random confirmation code
$confirm_code=md5(uniqid(rand()));
// values sent from form
$name=strip_tags($_POST['username']);
$email=strip_tags($_POST['email']);
$pass=strip_tags($_POST['pass']);
// Insert data into database
$sql="INSERT INTO temp SET code='$confirm_code', username='$name', email='$email', password='$pass'";
$result=mysql_query($sql);
if($result){
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://kaphp.f-snet.com/confirmation.php?passkey=$confirm_code";
$sentmail=mail("$email",'Registration Conformation',"$message");
header("Location:thankyou.html");
}
else {
echo "Not found your email in our database";
}
// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}
}else{
header("Location:badmatch.html");
}
}else{
header("Location:emailinuse.html");
}
}else{
header("Location:nameinuse.html");
}
}else{
header("Location:invalidname.html");
}
?>
Thank you.