REDIRECTING A PAGE
Posted: Mon Aug 04, 2008 3:41 pm
Hi everybody,
I have the following code and I would like to redirect the user to another page after been allow it. I've been using the header() funtion, but it can't be used after an echo tag. Can you please help me to identify a place where to locate that funtion?
This is my code:
I have the following code and I would like to redirect the user to another page after been allow it. I've been using the header() funtion, but it can't be used after an echo tag. Can you please help me to identify a place where to locate that funtion?
This is my code:
Code: Select all
<?PHP
// Configura los datos de tu cuenta
$dbhost='db22.perfora.net';
$dbusername='dbo252002289';
$dbuserpass='18WmZnT79';
$dbname='db252002289';
session_start();
// Conectar a la base de datos
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if ($_POST['username']) {
//Comprobacion del envio del nombre de usuario y password
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "Debes digitar un password";
}else{
$query = mysql_query("SELECT user_email,user_pwd FROM users WHERE user_email = '$username' AND user_activated='1'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['user_pwd'] != $password) {
echo "Login incorrecto";
}else{
$query = mysql_query("SELECT user_email,user_pwd FROM users WHERE user_email = '$username' AND user_activated='1'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
echo "Has sido logueado correctamente ".$_SESSION['s_username']." y puedes acceder al index.php.";
}
}
}
?>