/    Sign up×
Community /Pin to ProfileBookmark

form processing – redirect

Hi,

Got some work to do and dont know how to start.

I need to make html input form with 4 checkboxes (for date) and 4 radio buttons (for place).

When someone selects checkbox and radiobutton and press submit, should be redirected to specific html page.

Anyone can advice me how could I do that with php?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@hyperionXSFeb 27.2012 — Use the power of action attribute

<form method="POST" action="specific html page">

This will 'redirect' the user 'when' he presses submit.

If you want to redirect the user after you have handled the POST, then you should use
[code=php]
header('Location: specific html page');
exit;
[/code]
Copy linkTweet thisAlerts:
@kashmirs22authorFeb 27.2012 — Ok thats for the redirect part.

But how to redirect to specific pages based on checkbox and radiobuttons selection? Im missing php part where I should say something like

if users checkes 2nd box, and 1st radiobutton redirect to page1.html

if users chekcs 3rd box and 1st radiobutton redirect to page2.html

....

Thanks for feedback.
Copy linkTweet thisAlerts:
@hyperionXSFeb 27.2012 — [code=php]
if($_POST['submit']){
if($_POST['option1']=='1'){
header('Location: specific html page');
exit;
}elseif($_POST['option1']=='2'){
header('Location: specific html page');
exit;
}elseif($_POST['option1']=='3'){
header('Location: specific html page');
exit;
}
}
[/code]

Or use switch case. Anyway, it depends a lot on your code and what you want to do.
Copy linkTweet thisAlerts:
@kashmirs22authorFeb 27.2012 — form action="proces-booking.php" method="post">

13.06.2012. <input type="checkbox" name="option1[]" value="1" /> <br />

18.09.2012. <input type="checkbox" name="option1[]" value="2" /> <br />

22.09.2012. <input type="checkbox" name="option1[]" value="3" /> <br />

<input type="submit" value="Submit" name="Submit" />

</form>


and the following php:

<?php

if($_POST['submit']){

if($_
POST['option1'] == '1'){

header('Location: http://www.google.com/maps');

exit;

}elseif($_POST['option1']=='2'){

header('Location: http://google.com/images');

exit;

}elseif($_
POST['option1']=='3'){

header('Location: http://google.com/');

exit;

}

}

?>


Wont work. ?
×

Success!

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