/    Sign up×
Community /Pin to ProfileBookmark

i need help with a form were you select a radio button and then click submit … it all goes to 1 page but when you select a different radio buttons it changes what you see on the next page

if anyone understands this … then reply … any help will be appreciated … thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@patenaudematFeb 27.2005 — Use <INPUT TYPE="radio"> to display your buttons, and make sure the names of the buttons from the same group are the same. Also, don't forget to set VALUE in addition to what's between the input tags. Use "checked" to indicate which is selected. Example:
[CODE]
<INPUT TYPE="radio" NAME="group1" VALUE="a" checked> A</INPUT>
<INPUT TYPE="radio" NAME="group1" VALUE="b"> B</INPUT>
[/CODE]

On the server side, use $_GET or $_POST to get the value. Hope it helps!
Copy linkTweet thisAlerts:
@NogDogFeb 28.2005 — A bit more detail:

HTML form:
<i>
</i>&lt;!-- top of page precedes --&gt;
&lt;form action="redirect.php" method=post&gt;
&lt;p&gt;Go to:
&lt;input type=radio name=page value=1 checked&gt;Page 1
&lt;input type=radio name=page value=2&gt;Page 2
&lt;input type=radio name=page value=3&gt;Page 3
&lt;input type=submit name=go value="Go"&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;!-- rest of page follows --&gt;

redirect.php:
[code=php]
<?php
if(isset($_POST['page']))
{
$pages = array(1 => "page1.html",
"page2.html",
"page3.html");
if(array_key_exists($_POST['page'], $pages))
{
header("Location: http://www.mysite.com/" . $pages[$_POST['page']]);
exit;
}
}
# if we fell through to here, something's wrong or user got here
# without using our selection form, so display error:
?>
<html>
<head><title>Error</title></head>
<body>
<h1>Error</h1>
<p>There was an error processing your request. Please contact the webmaster.</p>
</body>
</html>
[/code]
×

Success!

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