Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.