Jump to content

<?php if ($_POST['Afloop_dag'] == "1") { echo "selected"; } ?>


stijn0713

Recommended Posts

I thought i add this piece of code:

<?php if ($_POST['Afloop_dag'] == "1") { echo "selected"; } ?>

in my options, like:

 

<option value="1" <?php if ($_POST['Afloop_dag'] == "1") { echo "selected"; } ?>>1</option>.

 

However, now it says that Afloop_dag index is undefined. However, i used this before in a signup code and it worked. why does the index need to be defined? im using it in a if statement

Link to comment
https://forums.phpfreaks.com/topic/265326--/
Share on other sites

Use isset to check if it isn't empty first.

 

I just felt like nit picking, if you want to check if it is not empty, use empty which will do an is set check as well. However, if you want to know if the variable has been previously set, and do not care if it is empty, false, null etc or not isset is the way to go.

Link to comment
https://forums.phpfreaks.com/topic/265326--/#findComment-1360313
Share on other sites

Use isset to check if it isn't empty first.

 

I just felt like nit picking, if you want to check if it is not empty, use empty which will do an is set check as well. However, if you want to know if the variable has been previously set, and do not care if it is empty, false, null etc or not isset is the way to go.

 

More nitpicking, isset will return FALSE if it's argument evaluates to NULL :D

Link to comment
https://forums.phpfreaks.com/topic/265326--/#findComment-1360327
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.