barbs75 Posted February 19, 2008 Share Posted February 19, 2008 Hey guys, I am trying to add the email activation script to my login system, but it doesnt seem to be working.... i have added the following code to check the status: else { //check that user has activated their account $sql_status_check = "SELECT * FROM customer WHERE username='$user'"; $status_check_result = mysql_fetch_array(mysql_query($sql_status_check)); $status_info = $status_check_result['status']; //if account hasnt been activated, throw error if ($status_info > 0) { $error = "You haven't yet fully activated your account. Please check your email inbox"; } Does that look correct?? is there anything i am missing? The full code of the whole page is shown below, in case i have missed out anything elsewhere in the script <?php session_start(); header("Cache-control: private"); $user = $_POST['username']; $pass = $_POST['password']; $con = mysql_connect("localhost","root","12waldron"); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customerhouses_db", $con); //Replace with your MySQL DB Name //change to database connection file // checking if the user exists $sql_user_check = "SELECT * FROM customer WHERE username='$user'"; //your table name here $result_name_check = mysql_query($sql_user_check); $usersfound = mysql_num_rows($result_name_check); // if user not found, note that and end if ($usersfound < 1) { $error = "User $user not found."; // if user does exist, continue with processing } else { // checking if passwords match $sql_pass_get = "SELECT * FROM customer WHERE username='$user'"; //your table name here $user_info = mysql_fetch_array(mysql_query($sql_pass_get)); $encryptpass = $user_info['encryptpass']; // if doesn't match, note that and end if ($encryptpass != md5($pass)) { $error = "Invalid password. Try again."; } else { //check that user has activated their account $sql_status_check = "SELECT * FROM customer WHERE username='$user'"; $status_check_result = mysql_fetch_array(mysql_query($sql_status_check)); $status_info = $status_check_result['status']; //if account hasnt been activated, throw error if ($status_info > 0) { $error = "You haven't yet fully activated your account. Please check your email inbox"; } else { //create sessions for each table entry $_SESSION['username'] = $user_info['username']; $_SESSION['title'] = $user_info['title']; $_SESSION['forename'] = $user_info['forename']; $_SESSION['surname'] = $user_info['surname']; $_SESSION['email'] = $user_info['email']; $_SESSION['encryptpass'] = $user_info['encryptpass']; $_SESSION['membership'] = $user_info['membership']; } } //checks username session is registered, if it isn't checks if a value is assigned to error, if it has been //output error and send them back to login screen, otherwise they are logged in correctly and welcome them if (!$_SESSION['username']) { if ($error) { echo $error; } else { include("welcome.php"); } //otehrwise they are still logged in and welcome them back! } else { echo "<html><head><title>Welcome Back</title></head><body>Welcome back ".$_SESSION['username']." <a href=\"settings.php\">Click here</a> to view your current settings.</body></html>"; } ?> cheers Craig Quote Link to comment Share on other sites More sharing options...
smithmr8 Posted February 19, 2008 Share Posted February 19, 2008 $sql_status_check = mysql_query("SELECT * FROM customer WHERE username='$user'"); $status_check_result = mysql_fetch_array($sql_status_check); $status_info = $status_check_result['status']; I never put mysql statements inside other statements. Might be your problem. Quote Link to comment Share on other sites More sharing options...
barbs75 Posted February 19, 2008 Author Share Posted February 19, 2008 hey smithmr8, Tried what you suggested, didnt help im afraid do you know anything else that might be wrong?? When i execute the login.php script from login_form.html, a white screen appears, so its not executing any of the code by the looks of things cheers Craig Quote Link to comment Share on other sites More sharing options...
smithmr8 Posted February 19, 2008 Share Posted February 19, 2008 That, for me anyway, means that somewhere in your script a mis-type or error has occurred. Did you change that for all 3 of the instances where you put the mysql_query inside mysql_fetch_array ? Quote Link to comment Share on other sites More sharing options...
barbs75 Posted February 19, 2008 Author Share Posted February 19, 2008 hey, no i didnt change it for all of the instances, i added the code for the status check to my login.php script, the script was working fine until i tried adding this script, so i dont see what the problem is.... My technique isnt wrong or anything is it?? cheers Craig Quote Link to comment Share on other sites More sharing options...
barbs75 Posted February 20, 2008 Author Share Posted February 20, 2008 hEY, I have solved this problem now, it was the fact that i had missed a bracket out, simple really cheers mr smith for all your help Craig Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.