jeff5656 Posted October 15, 2010 Share Posted October 15, 2010 I get the undefined index error for this code: if ($_SESSION['message_from_previous_page']){ echo $_SESSION['message_from_previous_page']; $_SESSION['message_from_previous_page'] =''; } The code does not die, but I want to address it. How do I deal with this if sometime $_SESSION['message_from_previous_page'] is undefined (like when a user first logs on and this variable is not yet assigned. I thought that putting it inside the if statement would work to "hide" the undefined variable but nope! Link to comment https://forums.phpfreaks.com/topic/215974-undefined-index-message_from_previous_page/ Share on other sites More sharing options...
Pikachu2000 Posted October 15, 2010 Share Posted October 15, 2010 See if it's set or not with isset(). if( isset($SESSION[''message_from_previous_page']) ) { Link to comment https://forums.phpfreaks.com/topic/215974-undefined-index-message_from_previous_page/#findComment-1122596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.