|
Posted by Vincent Delporte on 02/08/07 22:26
On Thu, 08 Feb 2007 15:51:36 +0100, Rik <luiheidsgoeroe@hotmail.com>
wrote:
>What's wrong with the following:
It works, but Kim above said: "Using empty() without checking the
variable with isset() might trigger a warning message on some systems.
("Variable not set")". Hence the use of IsSet() and Empty().
Any idea why this redisplays the form even when filling the two fields
in the form?
====================
$login = (isset($_POST["login"]) and !empty($_POST["login"])) ?
$_POST["login"] : NULL;
$password = (isset($_POST["password"]) and !empty($_POST["password"]))
? $_POST["password"] : NULL;
//BAD if(empty($login) or empty($password)) {
//BAD if(is_null($login) or is_null($password)) {
//BAD if(!$login or !$password) {
?>
<form action="<?php echo $PHP_SELF; ?>" method=POST>
Login: <input type="text" id ="login" name="login" size="20"
value=""><br>
Pass: <input type="password" id="password" name="password"
size="10" value=""><br>
<input type="submit" value="OK">
</form>
<?php
} else {
print "login = $login, password = $password";
}
====================
Thanks.
Navigation:
[Reply to this message]
|