physaux Posted October 15, 2009 Share Posted October 15, 2009 Full Header.php is: <?php $reset= false; $reset= strip_tags($_GET["reset"]); //THIS IS LINE 3 if(empty($reset)) $reset = false; if($reset==NULL) $reset=false; if($reset==true){ session_destroy(); header( 'Location: index.php' ) ; } ?> and i get the "Notice": Undefined index: reset in /Users/../header.php on line 3 What is going on? If you need more information, here is start and end of my main file, index.php <?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); session_start(); require_once("includes/header.php"); require_once("includes/constants.php"); //... ?> <a href="index.php?reset=true">CLICK HERE TO RESET AND DESTROY ALL DATA</a> So i only get this error when i go to index.php index.php?reset=true works for me, but the problem is later after it redirects me back to index.php, the "Notice" is displayed.. How do i fix this?? Link to comment https://forums.phpfreaks.com/topic/177841-solved-notice-undefined-index-reset-attempting-to-redirect-works-but-get-a-notice/ Share on other sites More sharing options...
waynew Posted October 15, 2009 Share Posted October 15, 2009 It basically means that you're trying to access an array index that does not exist. In this case, if the GET variable "reset" is not given to your script via the URL, that nasty little warning will raise it's head. As a general rule, you should always check that incoming GET and POST variables exist BEFORE trying to use them. <?php $reset= false; if(isset($_GET['reset'])){ $reset= strip_tags($_GET["reset"]); //THIS IS LINE 3 } if(empty($reset)) $reset = false; if($reset==NULL) $reset=false; if($reset==true){ session_destroy(); header( 'Location: index.php' ) ; } ?> Link to comment https://forums.phpfreaks.com/topic/177841-solved-notice-undefined-index-reset-attempting-to-redirect-works-but-get-a-notice/#findComment-937727 Share on other sites More sharing options...
physaux Posted October 15, 2009 Author Share Posted October 15, 2009 ah got it thank you! Link to comment https://forums.phpfreaks.com/topic/177841-solved-notice-undefined-index-reset-attempting-to-redirect-works-but-get-a-notice/#findComment-937730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.