Hello guys,
I’m trying to make a login system linked to a mySQL database and below is what I have so far. The problem I’m having is when I try to submit both a username and password, I think the database query is failing and it leads to a blank page. Any ideas?
Thanks you. Any help will be greatly appreciated.
Here’s the page I’m talking about: http://aerithea.com/login/login.php
[php]<?php
session_start();
?>
Member System - Login
<?php
$form = "
";
if ($_POST['loginbtn']) {
$user = $_POST['user'];
$password = $_POST['password'];
if ($user) {
if ($password) {
require("connect.php");
$password = md5(md5("q`wkIa4".$password."qwe;lnm"));
//make sure login info correct
$query = msql_query("SELECT * FROM users WHERE username='$user'");
$numrows = mysql_num_rows($query);
if ($numrows == 1) {
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if($password == $dbpass) {
if($dbactive == 1) {
//set session info
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You have been logged in as
$dbuser.
Click here to go to the member page.";
}
else
echo "You must activate your account to login. $form";
}
else
echo "You did not enter the correct password. $form";
}
else
echo "The username you entered was not found. $form";
mysql_close();
}
else
echo "You must enter your password. $form";
}
else
echo "You must enter your username. $form";
}
else
echo $form;
?>
[/php]
connect.php is:
[php]<?php
mysql_connect(“localhost”, “/database name/”, “/database password/”);
mysql_select_db(“users”);
?>[/php]