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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.