I am trying to make a login session with PHP and I recieve and error at "username" field of my database. My source code is here:
index.php
<?php
session_start();
if(isset($_POST['bttLogin'])){
require 'connect.php';
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysqli_query($con, 'SELECT * FROM account WHERE username=" '.$username.' " AND password="'.$password.' " ');
if (mysqli_num_rows($result)==1){
$_SESSION['username'] = $username;
header('Location: welcome.php');
}
else
echo "Account invalid";
}
if(isset($_POST['username'])){
$filename = $_POST['username'];
}
if (isset($_GET['logout'])){
session_unregister('username');
}
?>
<form method="post">
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td> Username </td>
<td><input type = "text" name="usermame"></td>
</tr>
<tr>
<td> Password </td>
<td><input type = "password" name="password"></td>
</tr>
<tr>
<td> </td>
<td><input type = "submit" name="bttLogin" value="Login"></td>
</tr>
</table>
</form>
I made my connection with my database, but it keeps saying that username is undefined. Please help. (Solved)