justlukeyou Posted February 18, 2013 Share Posted February 18, 2013 Hi, I am trying scan my table on the login page to detect an email address but I dont know what code I should use to read a row. If I enter "emailaddress@yahoo.com" in the form it does return the error message. However if enter "hello@yahoo.com" it returns the error message. if(($loginEmail) != ('emailaddress@yahoo.com')) { $errors['incorrectemail'] = "Your email address is incorrect."; } However when I try do to the following it is not scanning the table. Can anyone advise how I scan the table to determine if an email address in table? if(($loginEmail) ($row['email'])) { $errors['incorrectemail'] = "Your email address is incorrect."; } {/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 18, 2013 Share Posted February 18, 2013 You've got to be fucking kidding me. Quote Link to comment Share on other sites More sharing options...
Mko Posted February 18, 2013 Share Posted February 18, 2013 (edited) Are you trying to use a form to process this 'table'? If so, check out this link for some help. As to the if statement you posted at the bottom of your post, I'm confused as to what you're trying to do with it. Are you trying to do a comparison or an AND/OR statement? Edited February 18, 2013 by Mko Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted February 18, 2013 Author Share Posted February 18, 2013 (edited) Hi, I am trying to check if an email address is in the table. I can log in and create a session but I cant seem to return a message which says the email address is not in the table. Edited February 18, 2013 by justlukeyou Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted February 18, 2013 Author Share Posted February 18, 2013 You've got to be fucking kidding me. Hi Jessica, How do I scan the table to check if the email address is in the table? Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted February 19, 2013 Author Share Posted February 19, 2013 Hi, Does anyone have any suggestions please. I can log in and create a session, I just cant seem to be able to read the table. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted February 19, 2013 Share Posted February 19, 2013 You should read the information on positing. You have not psoted any relevant information, for example the table structure, full code and not a snippet. You also need to tell us exactly what's happening, error messages ect. Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted February 19, 2013 Author Share Posted February 19, 2013 Apologies, I will try and get more information. I just the row command would search the row. if(($loginEmail) != ($row['email'])) { $errors['incorrectemail'] = "Your email address is incorrect."; } Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted February 19, 2013 Author Share Posted February 19, 2013 Hi, This is the all the code. It is not returning any error messages. It logs in and does everything fine. If you wanted a user to be able to check if their email address is in the table how would you do this? I cant wee why what I am trying to do doesn't work. <?php if ($_SESSION['userLoggedIn']) session_start(); $_SESSION['userLoggedIn'] = 0; $_SESSION['userEmail'] = ''; $_SESSION['userID'] = ''; $_SESSION['userfirstname'] = ''; $_SESSION['usersurname'] = ''; // Reset errors and success messages $errors = array(); $success = array(); // Login attempt if(isset($_POST['loginSubmit']) && $_POST['loginSubmit'] == 'true') { $loginEmail = filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL); $loginPassword = trim($_POST['password']); $accounty = ('y'); if(count($errors) === 0) { $loginPassword = md5($loginPassword); $query = 'SELECT * FROM users WHERE email = "' . mysql_real_escape_string($loginEmail) . '" AND password = "' . $loginPassword . '" AND accountconfirmed = "' . $accounty . '"LIMIT 1'; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } if(mysql_num_rows($result) === 1) { $row = mysql_fetch_assoc($result); $_SESSION['userLoggedIn'] = 1; $_SESSION['userEmail'] = $loginEmail; $_SESSION['userID'] = $row['id']; $_SESSION['userfirstname'] = $row['firstname']; $_SESSION['usersurname'] = $row['surname']; header('Location: /test/board.php'); exit; } else { $errors['login'] = 'No user was found with the details provided.1.'; } } } /* The rest of your login page code */ // Reset errors and success messages $errors = array(); $success = array(); // Login attempt if(isset($_POST['loginSubmit']) && $_POST['loginSubmit'] == 'true'){ $loginEmail = trim($_POST['email']); $loginPassword = trim($_POST['password']); } if(!isset($loginEmail) || empty($loginEmail)) { $errors['loginEmail'] = "Please enter your email address."; } if(!isset($loginPassword) || empty($loginPassword)) { $errors['loginPassword'] = "Please enter your password."; } $accounty = ('Y'); if(($accounty) != ($row['accountconfirmed'])) { $errors['confirmedaccount'] = "Your account has not yet been confirmed. Please request a confirmation email."; } if(($loginEmail) != ('email@yahoo.com')) { $errors['incorrectemail'] = "Your email address is incorrect."; } if(($loginPassword) != ($row['password'])) { $errors['incorrectpassword'] = "Your password is incorrect."; } ?> 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.