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

 

Link to comment
Share on other sites

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 by denno020
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.