Party Animal Posted February 28, 2009 Share Posted February 28, 2009 Okay... I got a problem with html and php "talking" to each other. This is for a school assignment, and I've decided to go that little bit further... The idea is that there is 3 types of seating at a rock concert, and after selecting there decision, it will then re-direct to a new html page. The query, here: http://i44.tinypic.com/e9huli.jpg Okay, so, if the viewer selects blue, then submit, show an image of the blue type ticket that I am going to make later (On a different page, placed on the site template). Simple talk: Blue goes to "blue.html" Pink goes to "pink.html" Green goes to "green.html" After it is selected, and submit is pressed. The form in html: <form id="form1" name="form1" method="post" action=""> <label></label> <p> <label></label> <span class="style6">Select Your Seating: </span></p> <p> <label> <input name="radiobutton" type="radio" value="blue" /> Blue Seating</label><br /> <label> <input name="radiobutton" type="radio" value="pink" /> Pink Seating</label><br /> <label> <input name="radiobutton" type="radio" value="green" /> Green Seating</label> </p> <p>All seating includes around the clock access to the moshpit. </p> <p> <label> <input type="submit" name="submit" value="Submit" id="submit" /> </label> </p> </form> I don't know, and I can't find out how to get the php to do whatever it has too. If you guide me on the right track, that'd be great thanks. ~Party Animal Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/ Share on other sites More sharing options...
mjahkoh Posted February 28, 2009 Share Posted February 28, 2009 It goes lke this 1) assume the form above is named help.php 2) that the results form is named helpresults.php 3) in help.php post to helpresults.php 4) in helpresults.php before anything <? //we first test wether anything was posted if (!count($_POST['radiobutton']) ) { header("Location: help.php"); //Relocate back to main page } //echo 'radiobutton'.count($_POST['radiobutton']).'<br>'; //print_r ($_POST); ?> 5) Somewhere in the body of results page <? if ($_POST['radiobutton']='Green') { //generate code using javascript to display images. Note that ../images is a directory echo "<img src=\""."../images/myimage.jpg\"></a></td>"; } elseif ($_POST['radiobutton']='Blue') { //generate code using javascript to display images } else { } ?> U now know why the Maasai kill lions Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/#findComment-773126 Share on other sites More sharing options...
Party Animal Posted February 28, 2009 Author Share Posted February 28, 2009 So... 4 goes before the <html> and the doctype right? But I don't get where 5 goes... The body of the results page? Which is? Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/#findComment-773162 Share on other sites More sharing options...
Party Animal Posted March 1, 2009 Author Share Posted March 1, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/#findComment-773550 Share on other sites More sharing options...
Party Animal Posted March 2, 2009 Author Share Posted March 2, 2009 *sigh...* Bump. Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/#findComment-774957 Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 if (isset($_POST['submit'])) { if(isset($_POST['radiobutton'])) { $page = $_POST['radiobutton'] . ".php"; header("Location: $page"); } } else { echo "you did not select a seating section!"; } ?> </pre> <form id="form1" name="form1" method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>"> Select Your Seating: Blue Seating Pink Seating Green Seating All seating includes around the clock access to the moshpit. </form> <br><b Quote Link to comment https://forums.phpfreaks.com/topic/147276-form-query/#findComment-775005 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.