/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Where in this form can I put redirect

Where in this form can I include code to redirect me to a specific page. This is a submission form by godaddy and I have to use it the way they have it… although they say I can modify it. Currently, on submission, it redirects me to the index page, although no where in the code I see how it does that and I want to be able to specify the exact page it redirects to. Thanks.

[code=php]<?php
$request_method = $_SERVER[“REQUEST_METHOD”];
if($request_method == “GET”){
$query_vars = $_GET;
} elseif ($request_method == “POST”){
$query_vars = $_POST;
}
reset($query_vars);
$t = date(“U”);
$fp = fopen(“../data/gdform_$t”,”w”);
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,”<GDFORM_VARIABLE NAME=$key START>n”);
fputs($fp,”$valn”);
fputs($fp,”<GDFORM_VARIABLE NAME=$key END>n”);
if ($key == “redirect”) { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != “”){
header(“Location: http://”.$_SERVER[“HTTP_HOST”].”/$landing_page”);
} else {
header(“Location: http://”.$_SERVER[“HTTP_HOST”].”/”);
}

?>[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chazzyApr 26.2006 — this block right here determines where you get redirected to

[code=php]
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
[/code]
Copy linkTweet thisAlerts:
@NogDogApr 26.2006 — Add this hidden field to your form:
[code=html]
<input type="hidden" name="redirect" value="page.html">
[/code]

(Change "page.html" to whatever page you want it redirected to.)
Copy linkTweet thisAlerts:
@rch10007Apr 26.2006 — or you can just add the page you want to go to before the redirect is called:

[code=php]
$landing page = "whateverPage.php";
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
[/code]
Copy linkTweet thisAlerts:
@jamesx521authorApr 27.2006 — Add this hidden field to your form:
[code=html]
<input type="hidden" name="redirect" value="page.html">
[/code]

(Change "page.html" to whatever page you want it redirected to.)[/QUOTE]


Yes, thanks; that worked. I had tried that before and for some reason wasn't able to get it to work... that's when I started trying to do it from the PHP form instead and couldn't do it from there either.

With the PHP, I had tried many times and I did just try again by putting the page URL in the Landing page place, but never got it to work. Everytime on Submit it was getting me to the index page instead.

But luckily the <input type="hidden" name="redirect" value="page.html"> works fine now. Thanks.
×

Success!

Help @jamesx521 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,
)...