Okay, so, here's the thing.
I am trying to create a Membership system for my website and have ran into a problem.
After I complete the signup form, I am taken to the "Done!" page.
And the Users info is entered into the Database.
There is a link under that to activate the account, but whenever I click it, I get this error:
1Resource id #2Your account could not be activated!
I have no idea what is wrong, nor how to fix it.
My register.php looks like this:
<?
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$db_password = $_POST['passwd'];
$info = $_POST['info'];
/* Let's strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password = md5(stripslashes($db_password));
$info = stripslashes($info);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username) || (!$password)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
}
if(!$passwd){
echo "Desired Password is a required field. Please enter it below.<br />";
}
include 'join_form.html'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users
WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users
WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member
in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been used by another member
in our database. Please choose a different Username!<br />";
unset($username);
}
include 'join_form.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
// Enter info into the Database.
$db_password = md5($password);
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name,
email_address, username, password, info, signup_date)
VALUES('$first_name', '$last_name', '$email_address',
'$username', '$db_password', '$info2', now())")
or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
echo 'Done!<BR>';
echo "Click <a href=activate.php?id=".$username."&code=".$db_password.">Here</a> to activate your account!";
}
?>
And my activate.php looks like this:
<?
/* Account activation script */
// Get database connection
include 'db.php';
// Create variables from URL.
$userid = $_GET['id'];
$code = $_GET['code'];
$sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='".md5($code)."'");
echo $sql;
$sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='".md5($code)."' AND activated='1'");
echo $sql_doublecheck;
$doublecheck = mysql_num_rows($sql_doublecheck);
if($doublecheck == 0){
echo "<strong><font color=red>Your account could not be activated!</font></strong>";
} elseif ($doublecheck > 0) {
echo "<strong>Your account has been activated!</strong> You may login below!<br />";
include 'login_form.html';
}
?>
Please help, I would be most greatfull if somebody could help me sort this out.