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

Posted by Rik on 02/08/07 00:51

Vincent Delporte <justask@acme.com> wrote:

> On Thu, 08 Feb 2007 01:30:07 +0100, Rik <luiheidsgoeroe@hotmail.com>
> wrote:
>> While setting a variable to NULL will indeed return false with isset(),
>> the postfields are there. You're looking for empty() instead of isset().
>
> That did the trick, but why is isset() returning true even when I
> leave a field empty in a form?

Because sometimes fields are supposed to be sent empty. In other words,
there will be empty strings in the $_POST array. Empty strings aren't NULL.

> I'll take advantage of the thread to ask how to avoid FireFox's "The
> page you are trying to view contains POSTDATA" that is displayed when
> I hit F5 after the script returns, ie. when it displays $login and
> $passwor. Should I use those variables, and then empty them so Firefox
> is happy

To avoid processing the form again, you could set a post variable that has
to match a session variable you stored on creation of the form. You can
use this to prevent firing the process again.

This will not prevent the message of the browser though. A trick often
used for this is to send a redirect header after processing to the browser:
header('Location: http://example.com');

99,99% of browsers will obey and go to the new url. On a redirect, the
browser doesn't perform a post anymore, so hitting f5 after that won't
send a new post, and the browser won't complain.
--
Rik Wasmus

 

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

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