|
Posted by OmegaJunior on 01/15/07 21:46
On Mon, 15 Jan 2007 02:28:00 +0100, Jeff =
<it_consultant1@hotmail.com.NOSPAM> wrote:
> hey
>
> php 5.2.0
>
> I have problem with the code below. I haven't entered any values in th=
e
> secretAnswer input field, so when I submit the form the if test (see =
> below)
> isn't executed... I thought at least it should print out "no value".. =
but
> nothing is echoed to the screen...
>
> Any suggestions?
>
> <td align=3D"right" style=3D"width:40%;">
> <label for=3D"secretAnswer">Hemmelig svar:</label>
> </td>
> <td style=3D"width:60%;">
> <input type=3D"text" name=3D"secretAnswer" id=3D"secretAnswe=
r" /> *
> </td>
>
> $secretAnswer =3D $_POST["secretAnswer"];
> if (isset($secretAnswer)) {
> echo $secretAnswer;
> } else {
> echo "no value";
> }
>
>
The isset() function can be used to check whether a key exists in an =
array, as the other commenters showed:
if (isset($_POST['secretAnswer'])) { do something; }
It can't be used to see whether a variable holds a value, thus the use o=
f =
the empty() function in their examples.
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Navigation:
[Reply to this message]
|