Hi guys, i am currently doing a php app for school and the question is this, how can i make a popup window appear if the login is successful and redirect to another page (for example index.php) automatically in, lets say, 5 secs?
My login page as the following code (i am portuguese so some things are in PT but just say and i will translate),
I'm thankful for any help.
Peace and love,
Slaxer13
My login page as the following code (i am portuguese so some things are in PT but just say and i will translate),
Code:
<?php require_once('Connections/Info_Registos.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_Info_Registos, $Info_Registos);
$query_Login = "SELECT * FROM utilizador";
$Login = mysql_query($query_Login, $Info_Registos) or die(mysql_error());
$row_Login = mysql_fetch_assoc($Login);
$totalRows_Login = mysql_num_rows($Login);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['utilizador'])) {
$loginUsername=$_POST['utilizador'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login_incorreto.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Info_Registos, $Info_Registos);
$LoginRS__query=sprintf("SELECT utilizador, password FROM utilizador WHERE utilizador=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $Info_Registos) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
<style type="text/css">
@import url("style.css");
</style>
</head>
<body>
<h1><img src="images/Logo PAP 2.png" alt="" width="327" height="242" align="right">Login</h1>
<form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" name="Login">
<label>Utilizador:<br/></label>
<input type="text" name="utilizador"><br/>
<label>Password:<br/></label>
<input type="password" name="password"><br/><br/>
<input type="submit" value="Login"><br/><br/>
</form>
<a href="registo.php">Registar</a>
</body>
</html>
<?php
mysql_free_result($Login);
?>
Peace and love,
Slaxer13
Comment