code_god Posted December 7, 2013 Share Posted December 7, 2013 Please help I have this issue for a while and don't know how to fix the problem. I get an error message saying that there is an undefined index on line 9 and also line 10. I have no idea how to solve this so please help tim.php Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/ Share on other sites More sharing options...
jcbones Posted December 7, 2013 Share Posted December 7, 2013 Undefined index just means that you are asking for an array key that doesn't exist, or isn't defined. That should also show up as a notice, and not an error. <?php { $name = (isset($_POST['username'])) ? $_POST['username'] : NULL; $password = (isset($_POST['password'])) ? md5 ($_POST['password']) : NULL; echo $password; //if(isset($_POST['notify_box'])){ $notify = $POST['notify_box'];} } Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461572 Share on other sites More sharing options...
code_god Posted December 7, 2013 Author Share Posted December 7, 2013 Yh it does so how do I fix it?! Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461575 Share on other sites More sharing options...
jcbones Posted December 7, 2013 Share Posted December 7, 2013 The code snippet I gave you did fix the problem. It checks to see if the index exists, if it does it assigns it, if it doesn't it assigns a null value. Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461577 Share on other sites More sharing options...
code_god Posted December 7, 2013 Author Share Posted December 7, 2013 No mate it hasn't worked I still have the notice. Here they are: Notice: Undefined index: username in f:\easyphp1-8\www\tim.php on line 9Notice: Undefined index: password in f:\easyphp1-8\www\tim.php on line 10d41d8cd98f00b204e9800998ecf8427eMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 undefined x 1366 Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461579 Share on other sites More sharing options...
jcbones Posted December 7, 2013 Share Posted December 7, 2013 Post your script of line 5 through line 12. Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461580 Share on other sites More sharing options...
code_god Posted December 7, 2013 Author Share Posted December 7, 2013 </form> <?php { $name = ($_POST['username']); $password = md5 ($_POST['password']); echo $password; if(isset($_POST['notify_box'])){ $notify = $POST['notify_box'];} Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461581 Share on other sites More sharing options...
jcbones Posted December 7, 2013 Share Posted December 7, 2013 That doesn't look anything like the code snippet I gave you. Here it is again. { $name = (isset($_POST['username'])) ? $_POST['username'] : NULL; $password = (isset($_POST['password'])) ? md5 ($_POST['password']) : NULL; echo $password; //if(isset($_POST['notify_box'])){ $notify = $POST['notify_box'];} } Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461582 Share on other sites More sharing options...
code_god Posted December 7, 2013 Author Share Posted December 7, 2013 I have tried that and I still get the Notices Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461583 Share on other sites More sharing options...
desjardins2010 Posted December 7, 2013 Share Posted December 7, 2013 well your issue stands in the area echo "<br>"; if(!isset($_GET['r'])) { echo "<script language=\"javascript\"> <!-- document.location=\"$PHP_SELF?r=1&width=\"+screen.width+\"&Height=\"+screen.Height; //--> </script>"; } else { //CODE TO BE DISPLAYED IF RESOLUTION IS DETECTED if(isset($_GET['width']) && isset($_GET['Height'])) { echo $_GET['Height']." x ". $_GET['width']; } else { echo "resolution not detected"; } } ?> where are you defining "r" Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461584 Share on other sites More sharing options...
desjardins2010 Posted December 7, 2013 Share Posted December 7, 2013 if I remove that section of code the error is gone script acts as should... Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461585 Share on other sites More sharing options...
jcbones Posted December 7, 2013 Share Posted December 7, 2013 Here is your script running on my server: with the suggested fix. Name : Password : Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.22+ (KHTML, like Gecko) Chromium/17.0.963.56 Chrome/17.0.963.56 Safari/535.22+ undefined x 1920 PS, the issue in this case isn't $_GET['r'] because OP is already testing if it is set. Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461586 Share on other sites More sharing options...
code_god Posted December 7, 2013 Author Share Posted December 7, 2013 I re-read the code that you sent me and missed a couple of brackets out and it works now Cheers!! Link to comment https://forums.phpfreaks.com/topic/284606-help-undefined-index/#findComment-1461587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.