isset($var) question

From: Greg (greg_at_aperfectnumber.com)
Date: 03/28/05


Date: Mon, 28 Mar 2005 02:17:56 -0800

I have a question about the isset function. I was writing a script that
would check if a form was submitted and if there were values for all form
fields. Something like this:

FORM >submits to formhandler.php

<?

$name = $_POST['name'];
$date = $_POST['date'];

if (!isset($name) || !isset($date) )

    {
        do something;
    }

else if (isset($name) && isset($date) )

    {
        do something else;
    }

?>

The problem is that it would not recognize if the values were there or not,
and always executed the else statement. The fix was to change the "
if (!isset($name) || !isset($date) )" line to "if (!$name or !$date)" My
question is why it was not working before. Is the syntax not proper?

Thanks,

Greg



Relevant Pages

  • Re: isset($var) question
    ... Greg wrote: ... > I have a question about the isset function. ... I was writing a script that ...
    (alt.php)
  • Re: [WR] round tuits
    ... Jackson Pillock wrote: ... I do, too many projects going, not enough time, priorities lean toward ... I started writing a precinct drama set in a locked psychiatric ward. ... Sent off my script. ...
    (misc.writing)
  • Re: crisis Perl
    ... As to writing good code to begin with, ... the top of the script. ... the "use warnings;" line won't actually change ... recommended declaring variables IN AS SMALL AS SCOPE AS POSSIBLE. ...
    (comp.lang.perl.misc)
  • Marginally archaeaology: Eight scripts that still cant be read
    ... WRITING is one of the greatest inventions in human history. ... literate civilisation at the time of the ... So how do you decipher an unknown script? ... there must be some link to a known language. ...
    (sci.archaeology)
  • Re: Vinca script, cross bar angle - Ki Ri Ke
    ... of the Goddess, since the English title of the second book ... sacred script in The Goddesses and Gods of Old Europe, ... not exactly a scholarly publisher. ... writing scholars call "ideograms," and hence not as writing. ...
    (sci.lang)