I know this question was posted over and over, I've tried already to fix it with
if(isset($_POST['username'])) {} ... and check if $_POST is with capital letters and see if they are declared correct both in login form and in check_login script, I just can't find why is this happening.
Yesterday was all working fine, today when I open my pc I just try it to go further and suddenly it doesn't work anymore also the database table user was empty?! Im storing the database locally through xampp so no one could get into it,I don't know really what changed.
this is my login form :
<?php
session_start();
if(isset($_SESSION['memberlogged'])== true)
{
header("location: login_success.php");
}
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<center>
<body style="background-color:rgb(248,248,248);">
<div id="loginmenu">
<img src="/img/choose.jpg"><br>
<input type="text" name="username" id="unu" placeholder="username"> <br /><br>
<input type="password" name="password" id="unu" placeholder="password"> <br />
<br><input type="submit" value="Log in" id="button" onClick="parent.location='check_login.php'">
<div class="divider"></div>
<input type="submit" id="button2" onClick="parent.location='index.php'" value='Leave' name="leave">
</center>
</div>
</body>
</html>
and this is my check_login.php script
<?php
include ("config.php");
// username and password sent from form
$password=$_POST['password'];
$username=$_POST['username'];
// To protect MySQL injection
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query="SELECT * FROM users WHERE username='$username' and password='$password'";
$result=mysql_query($query);
// Mysql_num_row is counting table row
if($query)
{
$count=mysql_num_rows($result);}
else
{die ("something is not good");}
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// SAVE SESSION VARIABLES AND REDIRECT TO "login_success.php"
$_SESSION['username'] = $username;
$_SESSION['memberlogged'] = true;
header("location:login_success.php");
exit;
}
else {
echo "Wrong Username or Password";
}
?>
when I try to connect ( the login datas are 100% corect ) I get
Notice: Undefined variable: username in *********\check_login.php on line 6
Notice: Undefined variable: password in *********\check_login.php on line 7 Wrong Username or Password