Riseykins Posted April 23, 2008 Share Posted April 23, 2008 I've been using this tutorial: http://www.w3schools.com/php/php_post.asp and was wondering if it's possible to add radio buttons? Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/ Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Yes, you can use radio buttons. Do you need example code? Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525473 Share on other sites More sharing options...
Riseykins Posted April 23, 2008 Author Share Posted April 23, 2008 Yes, please. I am VERY new to PHP. I can just about figure out Wordpress, and can edit code, but cannot create it from scratch. xD Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525476 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Okay. If you had a form that looked like this: <form action="test_handle.php" method="POST"> Are you human? <input type="radio" name="human" value="Yes" />Yes <input type="radio" name="human" value="No" /> No <br /> <input type="submit" name="SubmitForm" value="Submit!" </form> Notice how they have the same name, but different values. <?php #test_handle.php if (isset($_POST['human'])) { $human = $_POST['human']; switch $human { case "Yes": echo "Good thing you're human!"; break; case "No": echo "Ah omg alien."; break; default: echo "Then what are you..."; break; } } else { echo "Please select an option next time."; } ?> Now, obviously, you could do more than that, but that should get you on the right track. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525478 Share on other sites More sharing options...
Riseykins Posted April 23, 2008 Author Share Posted April 23, 2008 OK, well this is my silly glitter crap again! Basically, I want people to be able to choose the style of their glitter text. By selecting a radio button, it will change the folder name that is generated... Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525492 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Post your form code and your PHP code. =) I'll fix it for you. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525493 Share on other sites More sharing options...
Riseykins Posted April 23, 2008 Author Share Posted April 23, 2008 LOL Thanks. N00b question, but how do I post code? I am not a forum kinda person! I am totally new to this and don't have a clue what I'm doing. I feel awful asking so many questions. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525494 Share on other sites More sharing options...
Dathremar Posted April 23, 2008 Share Posted April 23, 2008 I am not sure if i am getting the question right. But if you want to make something to change while you select an option you can list the options available in a list box and make a simple java script for the onChange event. If you need something like that tell me, i am willing to hlp. cheers Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525496 Share on other sites More sharing options...
Riseykins Posted April 23, 2008 Author Share Posted April 23, 2008 Glitter stye:<p /> Not here, yet!<p /> <form> Text: <input type="text" name="word" size="8" /><p /> <input type="submit" name="btn" value="Submit" /> </form><p /> <div class="h1">Preview</div> Click "submit" to see a preview.<p /> <?php if (isset($_GET['btn'])) { $word = $_GET['word']; $x = strlen($word); for ($i=0; $i<$x; $i++) { $c = $word[$i]; echo "<img src='http://www.burningviolet.com/glittergen/1/$c.gif' />"; } } ?> <p /> <div class="h1">Code</div> <textarea><?php if (isset($_GET['btn'])) { $word = $_GET['word']; $x = strlen($word); for ($i=0; $i<$x; $i++) { $c = $word[$i]; echo "<img src='http://www.burningviolet.com/glittergen/1/$c.gif' />"; } } ?></textarea> The folder named "1" is the folder that I want to change depending on what radio button has been selected. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-525503 Share on other sites More sharing options...
Riseykins Posted April 24, 2008 Author Share Posted April 24, 2008 Just a bump. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-526337 Share on other sites More sharing options...
Xurion Posted April 24, 2008 Share Posted April 24, 2008 Just an FYI, if you create a form and action to to a script with the following code, you'll see all the post variables displayed. <?php print_r($_POST); ?> Once you can see the post values, view the source; it's easier to look at. Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-526346 Share on other sites More sharing options...
Riseykins Posted April 24, 2008 Author Share Posted April 24, 2008 Heh. That makes no sense to me. I'm very much a beginner. This is the first thing I've ever attempted to do with PHP... Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-526361 Share on other sites More sharing options...
Xurion Posted April 24, 2008 Share Posted April 24, 2008 With a form, you have to supply the action parameter, for example: <form action="yourfile.php" method="post" name="yourform"> When the form is submitted, the values from the text fields, radio buttons etc. are all sent to the yourfile.php. You can then set this script to do things with those values. For a list of the values, use the script i supplied previously, or you can get a value by using the following code: <?php $yourvariable = $_POST['yourfield']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-526366 Share on other sites More sharing options...
Riseykins Posted April 25, 2008 Author Share Posted April 25, 2008 The thing that I'm finding hard is the fact that when you type a word in one box, an image is generated for each letter. So, each letter URL generated will also need to be modified by selecting different radio buttons. I just can't get it to list in the right order, so to speak... I don't know if this makes any sense! Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-527019 Share on other sites More sharing options...
Xurion Posted April 26, 2008 Share Posted April 26, 2008 No, it doesn't. Is your project online anywhere? Quote Link to comment https://forums.phpfreaks.com/topic/102604-radio-buttons-in-php-post/#findComment-527608 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.