You are here: [newbie] IsSet() tricky to use? « PHP Programming Language « IT news, forums, messages
[newbie] IsSet() tricky to use?

Posted by Vincent Delporte on 02/08/07 00:15

Hello

I'm learning how to use sessions to check at the top of every page
that the user has been authenticated, but I'm having a problem with
isset():

------------------------------------
<?php

if(!$PHPSESSID) {
//First time: Let's check login/passwd
//BAD $login = isset($_POST["login"])? $_POST["login"] : '';
$login = isset($_POST["login"])? $_POST["login"] : NULL;
$password = isset($_POST["password"])? $_POST["password"] :
NULL;

if(!isset($login) or !isset($password)) {
?>
<form action="<?php echo $PHP_SELF; ?>" method=POST>
Login: <input type="text" name="login"
size="20" value=""><br>
Pass: <input type="password" name="password"
size="10" value=""><br>
<input type="submit" value="OK">
</form>
<?php
} else {
//Shown after clicking on OK, even with
//one of the fields empty!
print "login = $login, password = $password";
}
} else {
print "session = ". $PHPSESSID . "<p>";
}

?>
------------------------------------

If the user doesn't fill in either the Login or Password field in the
form, I expected the empty field to return FALSE when passing it to
isset()... but this doesn't work. Obviously, I'm doing something wrong
:-/

Thanks for any tip :-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация