hi

I have a login form, when i tried to login i got this two errors:
Notice: Undefined index: username in C:\wamp64\www\FormTutorial\php\luana_login.php on line 6
Notice: Undefined index: password in C:\wamp64\www\FormTutorial\php\luana_login.php on line 7

I have been busting my head to figure out how to solve it so I went online to see if I can find a solution to fix the errors and I came across. I dont know how effective it is so
I have decide to give a tried to see how it work but this things when i put in my codes the errors gone but it give me a blank page when it should have give me the login form
to which i should be able to login.

this is the codes that I tried to use:

$username = @mysql_real_escape_string($_POST['user_name']);//when i add the code the errors is gone but give me a blank
$password = @mysql_real_escape_string($_POST['password']);

this is my codes below for the login form

<?php

        // capture values from the form and store in php variables

        $uname=($_POST['username']);
        $pword=($_POST['password']);

        //connection to the database

        $db_host='localhost';
        $db_username='root';
        $db_password="";
        $con=mysqli_connect($db_host, $db_username, $db_password) or die (mysqli_connect_error());

        //select the database to query
        mysqli_select_db($con, 'staff') or die (mysqli_error($con));
        $sql="SELECT * FROM applicant  WHERE uname ='$uname' AND pword=md5('$pword')";
        $result=mysqli_query($con,$sql) or die ("Error:" .mysqli_error($con));
        $rowcount=mysqli_num_rows($result);

        if($rowcount == 1)
        {
            session_start();
            $_SESSION['user']=$username;
            header("location:luana_profile.php");
        }
        else
        {
            echo"<script type=\"text/javascript\">
            alert('username and password doesn't exist');
            window.location\"../xhtml/luana_login.html\";
            </script>";
        }
        mysqli_close($con);

?>

how is that possible, what can i do to fix it or tell me what did i do wrong or is the codes is correct one to use

Take out the underscore. You have post elements username and user_name

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.