-3

I've got a problem in my log in system, I'm getting these errors:

Notice: Undefined index: username in C:\xampp\htdocs\Checkin\index.php on line 13
Notice: Undefined index: password in C:\xampp\htdocs\Checkin\index.php on line 14

The lines are like this:

    $db = new DB($db['host'], $db['gebruiker'], $db['wachtwoord'], $db['db']);
    $username = mysql_real_escape_string($_POST["username"]);
    $password = md5(md5($hotel["secret_salt"]) . md5($_POST["password"]));
    $find_sql = "SELECT look FROM users WHERE username = '{$username}' AND password = '{$password}'";
    $run_login = $db->query($find_sql);

So, what can i do, i hope someone knows a fix with like isset(); or empty();

Thanks

Wesley

user2966468
  • 1
  • 1
  • 2
  • 7

2 Answers2

0

Yes you are right. You need to make use of the isset construct. Do like this

<?php
    if(isset($_POST["username"]) && isset($_POST["password"]))
    {
    $db = new DB($db['host'], $db['gebruiker'], $db['wachtwoord'], $db['db']);
    $username = mysql_real_escape_string($_POST["username"]);
    $password = md5(md5($hotel["secret_salt"]) . md5($_POST["password"]));
    $find_sql = "SELECT look FROM users WHERE username = '{$username}' AND password = '{$password}'";
    $run_login = $db->query($find_sql);
    }
    else
    {
    echo "Username or Password was not passed";
    }
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0
if(isset($_POST['username']) && isset($_POST['password'])){
       $db = new DB($db['host'], $db['gebruiker'], $db['wachtwoord'], $db['db']);
       $username = mysql_real_escape_string($_POST["username"]);
       $password = md5(md5($hotel["secret_salt"]) . md5($_POST["password"]));
       $find_sql = "SELECT look FROM users WHERE username = '{$username}' AND password = '{$password}'";
       $run_login = $db->query($find_sql);

}
Bhadra
  • 2,121
  • 1
  • 13
  • 19