[PHP] Re: Userlogin system seems to override the if statement....

2005-10-12 Thread cc
did u give proper username and password to login with?

On 10/12/05, twistednetadmin <[EMAIL PROTECTED]> wrote:
> I'm new to this. So I used a tutorial to write this. But it shows "Login
> ok.
> Welcome" at once when the page loads. Here is the tutorial:
> http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf
>  include ("DBconnection");
>
>
> session_start();
> $err = 0;
> echo $err; //just to check. Shows 0
> $sql_login = sprintf("SELECT 'name', 'pass' FROM DB
> WHERE 'name'='%s' AND 'pass'='%s'", @$_GET['name'],@md5($_GET['pass']));
> $login = mysql_query($sql_login) or die(mysql_error());
> if (mysql_num_rows($login) == 0) {
> $GLOBALS['MM_username'] == @$_GET['name'];
> echo $err; //just to check. Shows 0
> session_register("MM_username");
> echo $err; //just to check. Shows 0
> $err = 1;
>
>
> }
> echo $err; //just to check. Shows 1
> ?>
> 
>  if ($err != 1) {
> if ($err == 2) { ?>
> There was an error processing your login.
> 
> 
> 
>
> 
> 
> Login as:
> 
> 
> 
> 
> Password:
> 
> 
> 
> 
> 
> 
> 
> 
>
>  }else{
> ?>
> Login ok. Welcome  echo "";
> }
> ?>
>
> I don't get any further. I must be missing something, but what??
>
> Please help.
>
> -Tore W-
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Userlogin system seems to override the if statement....

2005-10-12 Thread Mark Rees
-
sorry my mail reader didn't indent. comments in --


I'm new to this. So I used a tutorial to write this. But it shows "Login ok.
Welcome" at once when the page loads. Here is the tutorial:
http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf


There was an error processing your login.

}else{
?>
Login ok. Welcome ";


you will end up here if $err==1
Since you set $err=1; just before the if block begins, this is as expected.
You might find the section on if statements in the PHP manual has some
useful examples which might make things clearer:

http://uk2.php.net/if


The tutorial you are following is a bit ropey to be honest if this is the
dtandard of the code in it.


}
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php