/    Sign up×
Community /Pin to ProfileBookmark

redirect inside webform from formmail

I know this might be a bit tough to understand, but i am dying after 2 stupid weeks of trying to code this ONE STINKING LITTLE PIECE OF CODE. :p

My objective is to display a registration form. Once the user fills it in and selects one of 3 radio buttons at the end [Paypal, Check, Mail in payment], i want to write some code to plug into the value spot for my form so it redirects after is submits the form in an email.

<form name=”form2″ id=”form2″ method=”post” action=”formmail.php”>
<input type=”hidden” name=”recipient” value=”[email protected]” />
<input type=”hidden” name=”subject” value=”<?= $HTTP_POST_VARS[“courseid”].” – “.$HTTP_POST_VARS[“coursename”]; ?>”>
<input type=”hidden” name=”gmt_offset” value=”4″>
<input type=”hidden” id=”redirect” name=”redirect” value=”” />
<input type=”hidden” name=”coursename” value=”<?= $HTTP_POST_VARS[“coursename”]; ?>” />
<input type=”hidden” name=”courseid” value=”<?= $HTTP_POST_VARS[“courseid”]; ?>” />

<input type=”radio” name=”payment_type” value=”paypal” />Paypal<br />
<input type=”radio” name=”payment_type” value=”check” />Check<br />
<input type=”radio” name=”payment_type” value=”mail” />Mail in payment
</form>

There is still some basic form material missing, but plays no real part into any of this. My problem is if i put a strickt static value into the redirect hidden input box it goes there after the form is submitted.
— I NEED it to go to a specific location depending on what they select on the radio button. For example if they select the paypal button then i need the redirect value to equal “http://www.paypal.com” (obviously if it works in the end then i could change this to put the actual location in there). Or if they select either the mail or check buttons then it goes to a different location.

i have been trying javascript and PHP to get it to do this … i have even created another static php webpage that would try to redirect based on $_post[] posted variable from the payment type but i could not get it to read anything if the: Header( ‘Location: http://www.mypage.com‘) ; was not first.

PLEASE can someone give me a hand.
After 2 weeks i am starting to look at this code as if it is getting mail — repetitious.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcheryAug 09.2006 — put this in the header above everything on the page you will process to:
[code=php]
if(!empty($_POST['payment_type'])){
switch($_POST['payment_type']){
case 'paypal':
header("location:paypal.php?val={$_POST['someVal']}");
break;
case 'check':
header("location:check.php?val={$_POST['someVal']}");
break;
case 'mail':
header("location:mail.php?val={$_POST['someVal']}");
break;
default: echo "You should have not reached this page.";
}
}
[/code]
×

Success!

Help @Aceman 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...