/    Sign up×
Community /Pin to ProfileBookmark

PHP Redirect Issues. Help would be eternally appreciated. :)

Hello. I’m new to PHP. ?

I am trying to use the PHPlist manager for my e-mail lists and I’m running into problems with trying to redirect to the custom thank you page(s).

I’m trying to call this PHP snippet in the form element, but not sure how to setup the form to do so.

[code=php]function redirect($url) {
if (!headers_sent()) {
//If headers not sent yet… then do php redirect
header(‘Location: ‘.$url); exit;
} else {
//If headers are sent… do javascript redirect… if javascript disabled, do html redirect.
echo ‘<script type=”text/javascript”>’;
echo ‘window.location.href=”‘.$url.'”;’;
echo ‘</script>’;
echo ‘<noscript>’;
echo ‘<meta http-equiv=”refresh” content=”0;url=’.$url.'” />’;
echo ‘</noscript>’; exit;
}
} [/code]

Another member was kind enough to give me the snippet, but kind of left me hanging with how to use it the snippet bleow:

[code=php]
$url = “/redirect.php”; // This is the variable with the URL
redirect($url); // This is using the variable in the function
[/code]

From here, I’m not sure where to go next so I’m hopen that one of you other fine people would help me out?

Any help would be greatly appreciated.

Thanks
Brian

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@tfk11Mar 22.2009 — You should stick to URLs beginning with http for redirections... I believe most browsers will still figure it out but I wouldn't count on it.

The function you posted uses three separate methods of redirection which may be making it hard for you find out what is going on. I'd get rid of everything but the header() method and just make sure the headers don't get sent before you call the redirect function.

While debugging put an echo in place of the actual redirect so you can see what's going on. The firefox addon "httpFox" also allows you to browse through recent traffic including headers and content which is nice for debugging redirect issues.
Copy linkTweet thisAlerts:
@artemisMar 23.2009 — Just paste the code below what ever form handling you're doing.

Would be useful to see the rest of the code as well...
×

Success!

Help @jbg00d spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...