ShoeLace1291 Posted February 16, 2009 Share Posted February 16, 2009 I am trying to use variables such as $_GET and $_POST in my if statements for forms, etc. For example, I use if($_POST['submit']) to process my form, but I get an undefined index error. I get the same thing when I use $_GET with the switch function. Anyone know how to fix this? Link to comment https://forums.phpfreaks.com/topic/145368-undefinded-index-errors/ Share on other sites More sharing options...
genericnumber1 Posted February 16, 2009 Share Posted February 16, 2009 Show us some code? Link to comment https://forums.phpfreaks.com/topic/145368-undefinded-index-errors/#findComment-763152 Share on other sites More sharing options...
ShoeLace1291 Posted February 16, 2009 Author Share Posted February 16, 2009 if($_GET['action']){ $action = $_GET['action']; switch($action){ Gives me an undefined index error for that line. Link to comment https://forums.phpfreaks.com/topic/145368-undefinded-index-errors/#findComment-763154 Share on other sites More sharing options...
genericnumber1 Posted February 16, 2009 Share Posted February 16, 2009 <?php if(!empty($_GET['action'])){ Link to comment https://forums.phpfreaks.com/topic/145368-undefinded-index-errors/#findComment-763155 Share on other sites More sharing options...
wildteen88 Posted February 16, 2009 Share Posted February 16, 2009 Use isset: $action = isset($_GET['action']) ? $_GET['action'] : ''; Link to comment https://forums.phpfreaks.com/topic/145368-undefinded-index-errors/#findComment-763517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.