Jump to content

logining please help me


chriscloyd

Recommended Posts

<?
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 code
but i get this error
You 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
Share on other sites

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
Share on other sites

[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
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.