anshu Posted June 15, 2013 Share Posted June 15, 2013 Hello, I am new to PHP and trying to make thelogin page for my admin panel. My login page code is: <?php require_once('dbadmin.php'); $error = ''; $form = $_POST['submit']; $email = $_POST['email']; $password = $_POST['password']; if( isset($form) ) { if( isset($email) && isset($password) && $email !== '' && $password !== '' ) { $sql = mysql_query("SELECT * FROM `marti_admin` WHERE username='$email' and password='$password';"); if( mysql_num_rows($sql) != 0 ) { //success $_SESSION['logged-in'] = true; header('Location: data_insert.php'); exit; } else { $error = "Incorrect login info"; } } else { $error = 'Username/Password Incorrect';} } ?> ///////html code////// But i got these errors ( ! ) Notice: Undefined index: submit in C:\wamp\www\matri\login.php on line 4 Call Stack # Time Memory Function Location 1 0.0014 373944 {main}( ) ..\login.php:0 ( ! ) Notice: Undefined index: email in C:\wamp\www\matri\login.php on line 5 Call Stack # Time Memory Function Location 1 0.0014 373944 {main}( ) ..\login.php:0 ( ! ) Notice: Undefined index: password in C:\wamp\www\matri\login.php on line 6 Call Stack # Time Memory Function Location 1 0.0014 373944 {main}( ) ..\login.php:0 Please help me in removing these errors... Quote Link to comment https://forums.phpfreaks.com/topic/279210-notice-undefined-index-submit-in-cwampwwwmatriloginphp/ Share on other sites More sharing options...
denno020 Posted June 16, 2013 Share Posted June 16, 2013 (edited) You're doing the isset() test too late. You should assign the variables like this: if(isset($_POST['submit'])){ $form = $_POST['submit']; } //And the same with email and password. (or on one line) $form = isset($_POST['submit']) ? $_POST['submit'] : NULL; That will clear up your undefined index errors. And the reason you're getting the errors is most likely because the form that is submitting to this script either isn't passing the variables through with the same name, or the fields haven't been filled out in the form. Hopefully that'll help you out. Denno Edited June 16, 2013 by denno020 Quote Link to comment https://forums.phpfreaks.com/topic/279210-notice-undefined-index-submit-in-cwampwwwmatriloginphp/#findComment-1436213 Share on other sites More sharing options...
anshu Posted June 16, 2013 Author Share Posted June 16, 2013 @denno020 Now i got errors: ( ! ) SCREAM: Error suppression ignored for( ! ) Parse error: syntax error, unexpected $end in C:\wamp\www\matri\login.php on line 74 Quote Link to comment https://forums.phpfreaks.com/topic/279210-notice-undefined-index-submit-in-cwampwwwmatriloginphp/#findComment-1436221 Share on other sites More sharing options...
trq Posted June 16, 2013 Share Posted June 16, 2013 That is a simple syntax error which you need to learn to resolve yourself. If you can't, we need to see the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/279210-notice-undefined-index-submit-in-cwampwwwmatriloginphp/#findComment-1436227 Share on other sites More sharing options...
denno020 Posted June 16, 2013 Share Posted June 16, 2013 trq is right.. You'll need to bring all of your code here, and highlight which line 74 is.. In the process of doing that though, you'll see where the error is and probably be able to figure out the solution yourself. Denno Quote Link to comment https://forums.phpfreaks.com/topic/279210-notice-undefined-index-submit-in-cwampwwwmatriloginphp/#findComment-1436229 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.