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

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]


Удаленная работа для программистов  •  Как заработать на 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

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