SkyRanger Posted April 12, 2009 Share Posted April 12, 2009 I am getting this error, I probably looked at it 10x but keeps getting by me. I am missing something very obvious but can't seem to see it. Can somebody have a look at this and let me know what the problem is. The error I am getting is: Notice: Undefined index: Login in admin\index.php on line 19 which is: $Login=$_POST['Login']; I never started getting this error until I put in: $filename = '../install/index.php'; if (file_exists($filename)) { header('Location: ../install/index.php'); } else { error_reporting(E_ALL); $filename = '../install/index.php'; if (file_exists($filename)) { header('Location: ../install/index.php'); } else { // Use session variable on this page. This function must put on the top of page. session_start(); ////// Logout Section. Delete all session variable. session_destroy(); $message=""; ////// Login Section. $Login=$_POST['Login']; if($Login){ // If clicked on Login button. $username=$_POST['username']; $md5_password=md5($_POST['password']); // Encrypt password with md5() function. // Connect database. include '../inc/dbconnect.php'; mysql_connect($dbhost,$dbuname,$dbpass); mysql_select_db($dbname); // Check matching of username and password. $result=mysql_query("select * from admin where username='$username' and password='$md5_password'"); if(mysql_num_rows($result)!='0'){ // If match. session_register("username"); // Craete session username. header("location:calendar.php"); // Re-direct to calendar.php exit; }else{ // If not match. $message="--- Incorrect Username or Password ---"; $message1="--- Click below to recover password ---"; } } // End Login authorize check. ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ESSCalendar :: Administration</title> </head> <body> <table width="298" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="290"><center><? echo $message; ?></center></td> </tr> <tr> <td><center><? echo $message1; ?></center></td> </tr> </table> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <table width="400" border="1" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="100" rowspan="3" align="center" valign="middle"><img src="../images/callock.png"></td> <td width="79">User: </td> <td width="193"><input name="username" type="text" id="username" /></td> </tr> <tr> <td>Password: </td> <td><input name="password" type="password" id="password" /></td> </tr> <tr> <td colspan="2"><div align="middle"><input name="Login" type="submit" id="Login" value="Login" /></div></td> </tr> </table> </form> <div align="center"><a href="recover.php">Recover Password</a></div> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/153758-solved-undefined-index/ Share on other sites More sharing options...
.josh Posted April 12, 2009 Share Posted April 12, 2009 header('Location: ../install/index.php'); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/153758-solved-undefined-index/#findComment-808068 Share on other sites More sharing options...
SkyRanger Posted April 12, 2009 Author Share Posted April 12, 2009 Thanks Crayon. Tried that but still getting the same error Quote Link to comment https://forums.phpfreaks.com/topic/153758-solved-undefined-index/#findComment-808071 Share on other sites More sharing options...
jackpf Posted April 12, 2009 Share Posted April 12, 2009 I believe this notice occurs when you have used a superglobal something that doesn't exist. So does $_POST['login'] actually exist? If not, should do this: if(isset($_POST['login'])) { $login= $_POST['login']; } Quote Link to comment https://forums.phpfreaks.com/topic/153758-solved-undefined-index/#findComment-808072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.