Jump to content


Photo

Reload page


  • Please log in to reply
5 replies to this topic

#1 brittny85

brittny85
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationUtah

Posted 05 July 2006 - 10:50 PM

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...
//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


#2 mrwhale

mrwhale
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 06 July 2006 - 03:10 AM

Easiest way to reload:

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


#3 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 06 July 2006 - 03:24 AM

Try this

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

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


:: gucci.com ::
:: blockbuster.com ::

--------------------

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 04:23 AM

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. 
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 brittny85

brittny85
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationUtah

Posted 06 July 2006 - 04:38 PM

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

#6 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 07 July 2006 - 12:06 AM

Glad to be of help
:: gucci.com ::
:: blockbuster.com ::

--------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users