ecabrera Posted May 23, 2012 Share Posted May 23, 2012 I'm trying to get but does not work this is all in my login.php file <?php $fail = $_GET['login_failed']; if($fail){ echo "HELLO"; } ?> here is the rest of the code <?php session_start(); $email = $_SESSION['email']; $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); if(!empty($email) && isset($email) &&!empty($password) && isset($password)) { $password = md5("$password"); require "includes/init/db_con.php"; $query = mysql_query("SELECT * FROM users WHERE email = '$email'"); $numrows = mysql_num_rows($query); if($numrows != 0) { $row = mysql_fetch_assoc($query); $dbemail = $row ['email']; $dbpassword = $row ['password']; if($dbemail === $email && $dbpassword === $password) { $_SESSION['email'] = $dbemail; header("location: http://localhost/website/home.php"); } else { // Login failed because email or password did not match header('Location: login.php?login_failed'); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262962-login-get/ Share on other sites More sharing options...
smerny Posted May 23, 2012 Share Posted May 23, 2012 if(isset($_GET['login_failed'])){ echo "HELLO"; } Quote Link to comment https://forums.phpfreaks.com/topic/262962-login-get/#findComment-1347844 Share on other sites More sharing options...
cyberRobot Posted May 23, 2012 Share Posted May 23, 2012 $_GET['login_failed'] isn't set to anything in the header redirect. Try something like: <?php //... header('Location: login.php?login_failed=1'); //... ?> Quote Link to comment https://forums.phpfreaks.com/topic/262962-login-get/#findComment-1347931 Share on other sites More sharing options...
mrMarcus Posted May 23, 2012 Share Posted May 23, 2012 $_GET['login_failed'] isn't set to anything in the header redirect. Try something like: <?php //... header('Location: login.php?login_failed=1'); //... ?> Doesn't need to be. Using isset on $_GET['login_failed'] will return true even if it does not contain a value. Quote Link to comment https://forums.phpfreaks.com/topic/262962-login-get/#findComment-1347935 Share on other sites More sharing options...
Jessica Posted May 23, 2012 Share Posted May 23, 2012 Where is that section of code within the file? If it's inside of another if() you need to see if that's processing. Quote Link to comment https://forums.phpfreaks.com/topic/262962-login-get/#findComment-1348031 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.