Jump to content

Notice: Undefined index: submit in C:\wamp\www\matri\login.php


anshu

Recommended Posts

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... :(

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.