I have 2 accounts and there is a field in mysql called validated it can be either "true" or "false"
I tried writing a code so when the user logs in if the user is validated meaning $username = $_POST['username']; $validated = true $validation = a mysql query that selects validated from members where username = $username
$validated == $validation
and I have to accounts made 1 account username is "google" its validation is set to false 2nd account username is "jaydesigns" its validation is set to true
but when I login both come up as not validated
here is the page code:
Code: <?
include_once"config.php"; $final_report = "Please complete all the fields below.."; if(isset($_POST['login'])){ $username= trim($_POST['username']); $password = trim($_POST['password']); if($username == NULL OR $password == NULL){ $final_report = "Please complete all the fields below.."; }else{ $check_user_data = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); if(mysql_num_rows($check_user_data) == 0){ $final_report = "This username does not exist.."; }else{ $get_user_data = mysql_fetch_array($check_user_data); if($get_user_data['password'] == $password){
$start_idsess = $_SESSION['username'] = "".$get_user_data['username'].""; $start_passsess = $_SESSION['password'] = "".$get_user_data['password'].""; $validation = mysql_query("SELECT validated FROM `members` WHERE `username` = '$username'") or die(mysql_error()); $validated = "true"; if($validation == $validated) {
$final_report ="You are now logged in $start_idsess ";
} else {
$final_report ="Your account is not validated $start_idsess,
Please Activate your account from the email you recieved from us.
If you did not recieve an email click <a href='./activate-send.php'>here</a> to resend the email
You will be logged out Now"; session_unset('username'); session_unset('password');