PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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:
<?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.";
}
}
}
?>
<?php
function isValidUser($username,$password)
{
//sql stuff
$user = new User();//all your user data here, you define User to whatever you want
if ($valid)
return array(true,$user);
else
return array(false,$user);
}
?>
Hi guys,
Everah, is there a way to just make that "click to continue" as you recommend to appear as soon as the user has been authenticated?
Can you help me that way, please.
If you want to go the route of the "click here to continue" link, you could still use javascript to force the redirect as well. That way they will only need to click if they have javascript disabled.