skoobi Posted October 9, 2011 Share Posted October 9, 2011 Hi im sort of teaching myself how to code in php. even though i can do it there's still a few things im getting stuck on so im hoping someone will be able to help... Im currently going through a cms tutorial on the net (yes i know there's pre-made ones like joomla but i want to learn how they work) and ive got to the end of it but im getting this error... Notice: Undefined variable: HTTP_GET_VARS in C:\wamp\www\CustomCMS\cmsadmin\login.php on line 9 I know this is depreciated and you need to use the $_POST method now but as soon as i do that i get another error... Notice: Undefined index: user in C:\wamp\www\CustomCMS\cmsadmin\login.php on line 5 Heres the code for the login script.. <?php require_once("../includes/Sentry.php"); $sentry = new Sentry(); if ($HTTP_POST_VARS['user'] != ''){ $sentry->checkLogin($HTTP_POST_VARS['user'],$HTTP_POST_VARS['pass'],4,'welcome.php','failed.php'); } if ($HTTP_GET_VARS['action'] == 'logout'){ if ($sentry->logout()){ echo '<center>You have been logged out</center><br>'; } } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="25%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000066"> <tr> <td align="center" bgcolor="#000066"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Login</strong></font></td> </tr> <tr> <td bordercolor="#FFFFFF"><form name="form1" method="post" action="login.php"> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br> User: <input type="text" name="user"> </font></p> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Pass: <input type="password" name="pass"> </font></p> <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <input type="submit" name="Submit2" value="Submit"> </font></p> </form> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="login.php?action=logout">Logout</a> </font></div> </td> </tr> </table> </body> </html> Ive gone through the net trying to find a solution but i cannot find anything on this one... I dont mind going through every page sorting this out as its just a learning curve for me... If anyone could shed some light on this for me i would be most grateful... Thank you chris Link to comment https://forums.phpfreaks.com/topic/248726-http_post_vars-depreciated-problem/ Share on other sites More sharing options...
MasterACE14 Posted October 9, 2011 Share Posted October 9, 2011 just need to check for the existence of the $_POST variable. isset() <?php require_once("../includes/Sentry.php"); $sentry = new Sentry(); if (isset($_POST['user']) && isset($_POST['pass'])){ $sentry->checkLogin($_POST['user'],$_POST['pass'],4,'welcome.php','failed.php'); } if (isset($_GET['action']) && $_GET['action'] == 'logout'){ if ($sentry->logout()){ echo '<center>You have been logged out</center><br>'; } } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="25%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000066"> <tr> <td align="center" bgcolor="#000066"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Login</strong></font></td> </tr> <tr> <td bordercolor="#FFFFFF"><form name="form1" method="post" action="login.php"> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br> User: <input type="text" name="user"> </font></p> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Pass: <input type="password" name="pass"> </font></p> <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <input type="submit" name="Submit2" value="Submit"> </font></p> </form> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="login.php?action=logout">Logout</a> </font></div> </td> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/248726-http_post_vars-depreciated-problem/#findComment-1277370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.