Jump to content

Reload Page in a PHP Function


CloudSex13

Recommended Posts

a couple posts above you is a topic with lot's o' information on headers...for headers to work, there cannot be anything parsed to the browser before they are executed..

 

for example,

 

function omg() {
echo "money money.";
header("location: index.php");
}

echo'ing money money is causing the header to fail.

 

look into output buffering when getting involved with headers and such .. will save you many headaches.

 

as well, always have

error_reporting(E_ALL);

at the top of all your scripts when in development mode.  gives you a breakdown of any/all errors that occurred.

You can't put any content out to a browser before sending a header;

 

function omg() {
echo "money money.";
header("location: index.php");
}

 

will never work due to the line echo "money money.";

 

function omg() {
//echo "money money.";
header("location: index.php");
}

 

that will work

is there another way to do this with data output in a function without having to click another link?

 

The 'headers' redirection wuz also troubling me. What I did wuz simply wrote a small function:

function redirect($loc){
echo "<script>window.location.href='".$loc."'</script>";
}

 

and then

 

function GoHere(){
/*
	Do something here...
*/
redirect('index.php');
}

 

and it worked!

 

Hope this helps.

Archived

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

×
×
  • Create New...

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.