Re: isset(), empty(), $_GET and $_POST problem

From: Michael Austin (maustin_at_firstdbasource.com)
Date: 07/26/04


Date: Mon, 26 Jul 2004 02:32:34 GMT

Chung Leong wrote:
> "Dan" <agent@thwackspam.fathom.org> wrote in message
> news:5c08g0lv9te7dhhahudb4605la13rums13@4ax.com...
>
>>I was trying to troubleshoot a login page that doesn't work - it keeps
>>saying the login/password is missing - when my tracing discovered this
>>peculiar behavior.
>>
>>register_globals is off, so at the top of my script I assign a few
>>variables to incoming GET and POST values.
>>
>> $login = clean($_POST['login'], 30);
>> $passwd = clean($_POST['passwd'], 30);
>>
>> $message = $_GET['message'];
>>
>>clean() is simply a function that trims to the specified length and
>>applies EscapeShellCmd().
>>
>>Now, below that I have an if statement to check for whether a
>>login/password has been supplied or if an error message exists.
>>
>> if (isset($message) || empty($login) || empty($passwd))
>> {
>> // render the html page showing the form
>> } else {
>> // do some php/mysql stuff and redirect to another page
>> }
>>
>>Yet when I fill out those form fields and submit, it always redisplays
>>the form with my tracing errors stating that those fields are empty.
>>
>>When I echo out all $_GET and $_POST variables, indeed they are empty,
>>and strangely there is a $_GET['message'] that has no value, but
>>nevertheless is on the end of the url. (/index.php?message=) I can't
>>figure out how it got there. The form action is just "index.php" and
>>it uses the POST method, so what could be adding that GET variable?
>>
>>Now here's the weird part. If I simply add "1 ||" to the beginning of
>>that if statement, so basically it will always evaluate to true, then
>>suddenly the $_POST['login'] and $_POST['passwd'] are properly defined
>>and $_GET['message'] goes away!
>>
>>So this makes me wonder, are the isset() and empty() functions
>>actually modifying the variables passed to them somehow? And when I
>>put a true value in front of them, the if statement stops parsing
>>before it gets to those functions?
>
>
> Bet you a banana cupcake that your HTML is screwed up.
>
>

and how exactly are you sending both a _GET and _POST at the same time. A form
action can be EITHER GET or POST but not both. show us the complete <form> tag.

if you are POSTing your login/pass with a message then shouldn't you be looking
for _POST['message'] not _GET['message']

-- 
Michael Austin.
Consultant - Available.
Donations welcomed. http://www.firstdbasource.com/donations.html
:)


Relevant Pages

  • Re: Word Fields for Forms: Determining if Empty
    ... cCount = cCount + 1 ... "Jay Freedman" wrote: ... field contains five nonbreaking spaces (the 'empty' condition). ... IsNull has nothing whatever to do with form fields. ...
    (microsoft.public.word.docmanagement)
  • Re: isset(), empty(), $_GET and $_POST problem
    ... > Yet when I fill out those form fields and submit, ... > the form with my tracing errors stating that those fields are empty. ... > it uses the POST method, so what could be adding that GET variable? ...
    (comp.lang.php)
  • Re: Word Fields for Forms: Determining if Empty
    ... field contains five nonbreaking spaces (the 'empty' condition). ... "Jay Freedman" wrote: ... IsNull has nothing whatever to do with form fields. ...
    (microsoft.public.word.docmanagement)
  • database error - form field empty
    ... I am getting intermittent errors with a Front Page ASP form making a database ... and there are no empty fields in the table - I've triple checked ... [ODBC dBase Driver] System resource exceeded. ... One or more form fields were empty. ...
    (microsoft.public.frontpage.client)