Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi guys. Is it really necessary to set the $name,$email,$gender to NULL? If they are empty, aren't they null then? Thanks!

 

if (!empty($_REQUEST['name'])) {
$name = $_REQUEST['name'];
}
else {
$name = NULL;
echo '<p class="error">You forgot to enter your name!</p>';
}

Link to comment
Share on other sites

Thanks Sir, finding your book really helpful! I'm still a bit confused of the following. If nothing is typed into a particular input field in the form,doesn't that mean that the corresponding variable is unset and therefore Null?

Link to comment
Share on other sites

Hmm thanks Larry and HartleySan (yes, it helps). For the following piece of code, is setting the gender to NULL necessary or is it just a good programming practice? (since if gender is not set, then it automatically means its NULL) Thanks!

 

if (isset($_REQUEST['gender'])) {
$gender = $_REQUEST['gender'];
} else {
$gender = NULL;
}

Link to comment
Share on other sites

Ah I see, Thanks margaux! Another small doubt I have is on pg87, on script 3.5, shouldn't the form validation for $_POST['distance'] be using !empty function instead of isset since it's a text input ?

Link to comment
Share on other sites

 Share

×
×
  • Create New...