Note: When someone registers for an account, the registration form sends the information to three confirm tables in the same db. When you confirm, it keeps the information in the same db but moves it to new tables, then deletes the relevant entries from the original location. When someone registers, they are sent a confirmation email, with a link in it, the link looks like: www.yoursite.com/confirm.php?username=persons_username.
This is the updated code:
<?
include("config.php");
mysql_connect("$server", "$db_user", "$db_pass");
mysql_select_db($database);
$query = mysql_query("select * from confirm_login where username = '$username'");
$result = mysql_num_rows($query);
?>
<?
include("config.php");
mysql_connect("$server", "$db_user", "$db_pass");
mysql_select_db($database);
$query = mysql_query("select * from confirm_contactbook where username = '$username'");
$result = mysql_num_rows($query);
?>
<?
include("config.php");
mysql_connect("$server", "$db_user", "$db_pass");
mysql_select_db($database);
$query = mysql_query("select * from confirm_usermessages where tombr = '$username'");
$result = mysql_num_rows($query);
?>
<?
function confirm ($username) {
if (!$username) {
echo "Username already exists in the database.";
}
$query = "insert into login (`username`,`password`,`fname`,`sname`,`email`,`country`,`interests`,`age`,`iam`,`gender`,`school`,`status`,`aboutu`,`whyjoin`,`hobbies`, `userpic`, `userpicalt`, `newsletter`) values ('$username', '$password', '$fname','$sname', '$emaila', '$country', '$interests','$age', '$iam', '$gender', '$school', '$status', '$aboutu', '$whyjoin', '$hobbies', '$userpic', '$userpicalt', '$newsletter')";
$is_success_first = mysql_query($query) or die (mysql_error);
if ($is_success_first) {
$query2 = "insert * into contactbook (`username`,`contactuser`) values ('$username','$contactuser')";
$is_success_second = mysql_query($query2) or die (mysql_error);
}
if ($is_success_second) {
$query3 = "insert into usermessages (nomer`,`frommbr`,`tombr`,`title`,`message`,`date`,`new`) values ('$nomer','$frommbr','$tombr','$title','$message','$date','$new')";
$is_success_third = mysql_query($query3) or die (mysql_error);
}
if ($is_success_third) {
$query4 = "delete from confirm_login where username = '$username'";
$is_success_fourth = mysql_query($query4) or die (mysql_error);
}
if ($is_success_fourth) {
$query5 = "delete * from confirm_contactbook where username = '$username'";
$is_success_fifth = mysql_query($query5) or die (mysql_error);
}
if ($is_success_fifth) {
$query6 = "delete from confirm_usermessages where tombr = '$username'";
$is_success_sixth = mysql_query($query6) or die (mysql_error);
}
mysql_close();
if (!$is_success_second) {
mail("$emaila", "Registration Error", "Thank You, $fname $sname for trying to register. Unfortunately due to an unknown database fault\n
we were unable to add your complete information to the database. So please contact support.", "From: Braille School Accounts <accounts@brailleschool.com>");
}
if (!$is_success_third) {
mail("admin@brailleschool.com", "Alert, Purge Account!!!", "Hey man, looks like your database sucked at the wrong moment, luckily the registrant was able to stuff in their
information into the database at the right time and place, but something happened and I wasn't able to remove their entry from
the confirmation tables.", "From: Braille School Accounts <accounts@brailleschool.com>");
}
mail("$emaila", "Braille School Account Confirmed", "Thank You, $fname $sname for registering. Here is the information we recieved :\n
Username: $username
Password: $password
Email Address: $emaila
First Name: $fname
Last Name: $sname
Country: $country
Interests: $interests
Age: $age
You Are: $iam
Gender: $gender
School: $school
Marital Status: $status
About You: $aboutu
Why Join: $whyjoin
Hobbies: $hobbies
Receive Newsletter?: $newsletter\nCordially,
Blindness Related Learning.", "From: Braille School Accounts <accounts@brailleschool.com>");
}
?>
When I go to confirm.php?username=persons_username
I get no errors, and only a blank screen. Still fails to do its job.
All I am looking to do is get the person to confirm their email address via an automated email, before the account is live.