brittny85 Posted July 5, 2006 Share Posted July 5, 2006 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 notfunction 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.phpif (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] Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/ Share on other sites More sharing options...
mrwhale Posted July 6, 2006 Share Posted July 6, 2006 Easiest way to reload:[code]<script language='javascript'>window.location.href='http://www.yoursite.com/index.php?page=blah';</script>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/#findComment-53664 Share on other sites More sharing options...
Drumminxx Posted July 6, 2006 Share Posted July 6, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/#findComment-53665 Share on other sites More sharing options...
.josh Posted July 6, 2006 Share Posted July 6, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/#findComment-53682 Share on other sites More sharing options...
brittny85 Posted July 6, 2006 Author Share Posted July 6, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/#findComment-53974 Share on other sites More sharing options...
Drumminxx Posted July 7, 2006 Share Posted July 7, 2006 Glad to be of help Quote Link to comment https://forums.phpfreaks.com/topic/13796-reload-page/#findComment-54169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.