Jump to content

Archived

This topic is now archived and is closed to further replies.

brittny85

Reload page

Recommended Posts

I'm working on setting up a page that I need to have reload if it gets to a certain point in the code, but I can't seem to find anywhere what the code is to reload a page in PHP.  If it gets to this point then I don't want the form that is coded in below it to show up but for it to just go to the rest of the code.  I'll post the code and see if I can make my question make more sense...
[code]
//this is here to check if someone is logged in or not
function checkLogin()
{
if(!isset($_SESSION['memberid']))
{
include("headers/loginform.php");
exit;
}
}


//..lots of content that i only want loaded if checkLogin() succeeds

//this is essentially what is contained in loginform.php
if (isset($_POST['login']))
{
$user = $_POST['user'];
$pass = $_POST['pass'];
require("../headers/dbheader.php");
$person = mysql_query("SELECT * FROM [i]databasename[/i] WHERE uname = '$user' AND pw = '$pass'") or die(mysql_error());

if(mysql_num_rows($person) >0)
{
$person = mysql_fetch_array($person);
session_start();
$_SESSION['memberid'] = $person['memberid'];
[b][i]//This is where I want to get the page to reload[/i][/b]
else
{
$error = true;
}
}
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<p>Username: <input type="text" name="user" /></p>
<p>Password: <input type="password" name="pass" /></p>
<p><input type="submit" name="login" value="Log In" /> code]

I hope my question makes sense!  Thank you!
-Brittny[/code]

Share this post


Link to post
Share on other sites
Easiest way to reload:

[code]<script language='javascript'>
window.location.href='http://www.yoursite.com/index.php?page=blah';
</script>[/code]

Share this post


Link to post
Share on other sites
Try this

[code]
//this is here to check if someone is logged in or not

if(!isset($_SESSION['memberid']))
{
header("Location: loginform.php");
exit;
}

[/code]

Share this post


Link to post
Share on other sites
mrwhale i thought i'd point out that the javascript statement you supplied is useless in a php script, as javascript will only be parsed after all of the php is parsed, and the html (including the javascript) is sent to the client. 

Share this post


Link to post
Share on other sites
Thank you so much!  I thought that was what I was going to want to do but it hadn't been working so I thought I must have had something wrong.  It works fantastically now!  Thanks again!  ;D

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.