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');
}
?>
php header() Login problem
Moderator: General Moderators
Re: php header() Login problem
I'd start by looking through config.inc
Re: php header() Login problem
<?php
$hostname = 'hostname';
$dbname = 'dbname';
$username = 'username';
$password = 'pass;
mysql_connect($hostname, $username, $password);
mysql_select_db($dbname) ;
?>
This is config.inc !All the data is correct!
$hostname = 'hostname';
$dbname = 'dbname';
$username = 'username';
$password = 'pass;
mysql_connect($hostname, $username, $password);
mysql_select_db($dbname) ;
?>
This is config.inc !All the data is correct!
Re: php header() Login problem
Maybe somebody can give me an alternative to header for redirecting...I've tried meta refresh option but it failed. I've tried to use ob_start(),ob_flush(), but it looks like my server doesn't support Output buffering.