chriscloyd Posted July 4, 2006 Share Posted July 4, 2006 <?include("db_config.php");$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_POST['username'])) { $username = $_POST['username']; $password = md5($_POST['password']); $Login = mysql_query("SELECT username, password FROM users WHERE username='$username' AND password='$password'"); $LoginRS = mysql_query($Login) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $Loginadmin = mysql_query("SELECT username FROM admin WHERE username='$username'"); $LoginRSadmin = mysql_query($Loginadmin) or die(mysql_error()); $loginFoundadmin = mysql_num_rows($LoginRSadmin); if ($loginFoundadmin) { $GLOBALS['admin'] = $username; session_register("admin"); } $GLOBALS['username'] = $username; session_register("username"); header("../index.php"); } else { header("../index.php?p=sorry"); } }?>thats my codebut i get this errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #4' at line 1 Link to comment https://forums.phpfreaks.com/topic/13605-logining-please-help-me/ Share on other sites More sharing options...
micah1701 Posted July 4, 2006 Share Posted July 4, 2006 for starters, change[code] $Loginadmin = mysql_query("SELECT username FROM admin WHERE username='$username'"); $LoginRSadmin = mysql_query($Loginadmin) or die(mysql_error());[/code]to[code] $Loginadmin = "SELECT username FROM admin WHERE username='$username'"; $LoginRSadmin = mysql_query($Loginadmin) or die(mysql_error());[/code]see if that helps Link to comment https://forums.phpfreaks.com/topic/13605-logining-please-help-me/#findComment-52719 Share on other sites More sharing options...
chriscloyd Posted July 4, 2006 Author Share Posted July 4, 2006 and it wont redirect them to the index.php Link to comment https://forums.phpfreaks.com/topic/13605-logining-please-help-me/#findComment-52723 Share on other sites More sharing options...
micah1701 Posted July 4, 2006 Share Posted July 4, 2006 [quote]and it wont redirect them to the index.php[/quote][code]header("../index.php");[/code]headers do lots of stuff. one of them is forwarding, but you need to tell it to forward using "Location:"[code]header("Location: ../index.php");[/code] Link to comment https://forums.phpfreaks.com/topic/13605-logining-please-help-me/#findComment-52727 Share on other sites More sharing options...
chriscloyd Posted July 4, 2006 Author Share Posted July 4, 2006 thanks it works bye Link to comment https://forums.phpfreaks.com/topic/13605-logining-please-help-me/#findComment-52728 Share on other sites More sharing options...
Recommended Posts