0
<form action='login.php' method='POST'>
    Username: <input type='text' name='Username'><BR>
    Password: <input type='password' name='Password'><BR>
    <input type="checkbox" name="remember" >  Rember Me
    <input type='submit' value='Log in'>
    <a href="reg.php"> Register </a>

<?php
session_start();
include 'db.php';

$Username = $_POST['Username'];
$Password = $_POST['Password'];

if ($Username&&$Password)
{ 
$query = mysql_query("SELECT * From Users WHERE Username='$Username'");

$numrow = mysql_num_rows($query);

if ($numrow!=0)

{
    while ($row = mysql_fetch_assoc($query))
    {
      $Username = $row['Username'];
      $Password = $row['Password'];
    }

    // check to see if they match
    if ($Username==$Username&&$Password==$Password)
    {
      echo "You're in. <a href='index.php'>Click</a> here to enter the member page";
      $_SESSION['Username']=$Username;
    }

    else
      echo "Incorrect password";
}
else 
  die("That user doesn't exist");

}
else 
  die ("please enter a username and a password");

?>

The error im getting is :

Notice: Undefined index: Username in /home/stud/0/1314683/public_html/MathsrUs/login.php on line 48 Notice: Undefined index: Password in /home/stud/0/1314683/public_html/MathsrUs/login.php on line 49

1 Answers1

0

There is no data in $_POST

$Username = $_POST['Username'];

$Password = $_POST['Password'];

Check if page get accessed with via POST, you can check if with $_SERVER['REQUEST_METHOD'] variable.

Randomius
  • 252
  • 1
  • 2
  • 12