chemman14
12-02-2010, 08:20 PM
I am trying to make a login system with php that sends a user to a specific page based upon their username. This is the code that I currently have for the login check system
<?php
session_start();
if($_SERVER['REQUEST_METHOD'] == "POST") {
mysql_connect("localhost", "root", "admin");
@mysql_select_db("members") or die( "Unable to connect to database");
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$result = mysql_query("SELECT * FROM users WHERE username='$username' AND
password=md5('$password')");
if(mysql_num_rows($result) == 1) {
$_SESSION['is_logged_in'] = 1;
}
}
if(!isset($_SESSION['is_logged_in'])) {
header("Location:login.php");
} else {
header("Location: {$result['homepage']}");
}
?>
when I login on my login page my browser just takes me to a blank page with http://localhost/xampp/site/check.php in the address bar.
Any help is greatly appreciated! Thanks in advance
<?php
session_start();
if($_SERVER['REQUEST_METHOD'] == "POST") {
mysql_connect("localhost", "root", "admin");
@mysql_select_db("members") or die( "Unable to connect to database");
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$result = mysql_query("SELECT * FROM users WHERE username='$username' AND
password=md5('$password')");
if(mysql_num_rows($result) == 1) {
$_SESSION['is_logged_in'] = 1;
}
}
if(!isset($_SESSION['is_logged_in'])) {
header("Location:login.php");
} else {
header("Location: {$result['homepage']}");
}
?>
when I login on my login page my browser just takes me to a blank page with http://localhost/xampp/site/check.php in the address bar.
Any help is greatly appreciated! Thanks in advance