Open new window and auto-close the window
Posted: Sun Jun 18, 2006 9:14 pm
As we all here are familiar with phpBB, you know how when you get a PM a little window pops up, and after you click on the link, the window closes and the page loads in the "main" original window? Well, I'm trying to do something similar on my site. Here's the scenerio:
A user is currently on index.php and is logging in. The information is posted to user_login.php which is to open in a new window and display "Thank you for logging in, $username" After 2 seconds, I'd like the pop-up window to close and then have index.php reload itself.
I'm really not sure where to begin. I have some Javascript, but it isn't working too well.
Here is my user_login.php page that receives the login information and processes everything from there. This is the window that opens as a pop-up and is to close after 2 seconds and load index.php?mode=main in the main window:
A user is currently on index.php and is logging in. The information is posted to user_login.php which is to open in a new window and display "Thank you for logging in, $username" After 2 seconds, I'd like the pop-up window to close and then have index.php reload itself.
I'm really not sure where to begin. I have some Javascript, but it isn't working too well.
Here is my user_login.php page that receives the login information and processes everything from there. This is the window that opens as a pop-up and is to close after 2 seconds and load index.php?mode=main in the main window:
Code: Select all
<?php
include('include/remote.php');
$user = $_POST['user'];
$pass = md5($_POST['password']);
$match = "SELECT user_id FROM phpbb_users WHERE username = '".$_POST['user']."'
and user_password = '".md5($_POST['password'])."';";
$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "<div align=\"center\">";
echo "Sorry, there is no username \"$user\" with the specified password. Please check your information.<br>";
echo "<a href=\"javascript: history.go(-1);\">Try again</a>";
echo "</div>";
exit;
} else {
session_start();
$_SESSION['tsnhosting_username'] = $user;
//setcookie("loggedin", "TRUE", time()+(3600 * 24));
//setcookie("tsnhosting_username", "$user");
echo "<div align=\"center\">";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=javascript:window.open('index.php?mode=main','_parent');\">Thank you for logging in, $user! Please wait...<br>";
echo "</div>";
}
//echo "</div>";
mysql_close();
?>