Jump to content

Query


IvanGS
 Share

Recommended Posts

o meu código está assim...

session_start();
include('functions.php');
include('_mysql.php');
$user_login = addslashes($_POST['myusername']);
$pass_login = addslashes($_POST['mypassword']);

$query = sprintf("SELECT user, pass FROM users where user= '".$user_login."' AND pass= '".$pass_login."'",
    mysql_real_escape_string($user),
    mysql_real_escape_string($pass));

$result = mysql_query($query);
$num_rows = mysql_num_rows($result); 


echo $query;

if ($num_rows == 1){
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
        $_SESSION['username']= $row['user'];
        $_SESSION['logged'] = 1;
    }
    //js_redirect('demo.php',0);
}else{
   // js_redirect('demo.php?a=0',0);
    $_SESSION['username']= $user;
}
mysql_close($con);

e diz-me isto : Notice: Undefined variable: pass in C:\Program Files\EasyPHP-5.3.3\www\TESTE_LOGIN\login.php on line 10

essa variavel pass e a pass que está na query...

Link to comment
Share on other sites

estas a tentar usar a mesma variável mas com dois nomes diferentes:

session_start();
include('functions.php');
include('_mysql.php');
$user_login = addslashes($_POST['myusername']);
$pass_login = addslashes($_POST['mypassword']);

$query = sprintf("SELECT user, pass FROM users where user= '".$user_login."' AND pass= '".$pass_login."'",
    mysql_real_escape_string($user),
    mysql_real_escape_string($pass));
...

...Join the dark side...and get a free cookie...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.