Hey there guys, I have been trying to resolve this myself the past hour or so and I can't seem to figure it out. I am in the middle of programming a contacts database, with a login system. Now, the register.php file I created to create users for the database works, but the following code is from my login.php file.
When I am on the page in my browser and I type in a registered username and password combination it simply just reloads the login.php file, with blank form fields, as if you had just loaded the page. I am not quite sure what is causing this.
Here is the code from my login.php file:
<?php
//Database Information
$dbhost = "removed_for_this_post"; //Host Name
$dbname = "removed_for_this_post"; //Database Name
$dbuser = "removed_for_this_post"; //Database Username
$dbpass = "removed_for_this_post"; //Database Password
//Connect To Database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
$error = "Bad Login";
include "login.html";
} else {
$_SESSION['username'] = "$username";
include "main_interface.php";
}
?>
Thanks for your help in advance!!