php header() Login problem
Posted: Tue Sep 27, 2011 5:14 am
Hello!
I have this code for my login form.When i try it on my local server it works.But online it doesn't.I'm thinking it's because the online server send a header (header sent x-powered-by: php/5.2.17) before i can send mine!Take a look at my code and please tell me what you think!
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM client WHERE (user = '" . mysql_real_escape_string($_POST['user']) . "') and (pass = '" . mysql_real_escape_string(($_POST['pass'])) . "')");
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['user'] = $_POST['user'];
// Jump to secured page
header('Location: index.php');
}
else {
// Jump to login page
header ('Location:login.php');
}
?>
I have this code for my login form.When i try it on my local server it works.But online it doesn't.I'm thinking it's because the online server send a header (header sent x-powered-by: php/5.2.17) before i can send mine!Take a look at my code and please tell me what you think!
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM client WHERE (user = '" . mysql_real_escape_string($_POST['user']) . "') and (pass = '" . mysql_real_escape_string(($_POST['pass'])) . "')");
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['user'] = $_POST['user'];
// Jump to secured page
header('Location: index.php');
}
else {
// Jump to login page
header ('Location:login.php');
}
?>