My PHP login system doesn't work. My dbms is: phpMyAdmin. The connection is done in a different 'include' file. But I can't spot where and why my login system doesn't work.
html form:
<form id="form" action='index.php' method='post' enctype="multipart/form=data">
Username: <input type='text' name='liusername'>
Password: <input type='password' name='lipassword'>
<input type='submit' value='Login' name="lisubmit">
</form>
php code:
<?php
isset ($_POST ['lisubmit']) {
// Run the log in script here
$username = strip_tags($_POST['liusername']);
$password = strip_tags($_POST['lipassword']);
//find the record in database that corresponds to this user
$query = "SELECT user_id, user_password FROM user WHERE user_username = '".$_POST['liusername']."'";
//test to see if the password from the form is dame in database
if ($row['user_password'] == $_POST ['lipassword'] && $row['user_username'] == $_POST ['liusername']) {
$_SESSION ['loggedin'] = true;
$_SESSION ['id'] = $row['user_id];
} else {
$_SESSION['loggedin'] = false;
$_SESSION ['id'] = 0;
}
if ($_SESSION ['logginin') == true) {
echo "<p>You are loggin in</p>\n";
} else {
echo "<p>You are NOT logged in</p>\n";
}
?>
database connection file:
<?php
session_start();
$hostname = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbase = "assignment";
mysql_connect($hostname, $dbusername, $dbpassword) or die(mysql_error());
mysql_select_db($dbase) or die(mysql_error());
?>