ottz0 Posted March 4, 2009 Share Posted March 4, 2009 I have a form with radio buttons for a list of different seminars on different dates http://www.hayesbusiness.com.au/workshops.html When book online is pressed it goes to a php page. At this stage it is just a confirmation but I will pass this onto a payment gateway at a later stage. I want the confirmation to display the selcted seminar. I have some seminar codes as values for the radio and want to then use a string for which one they choose. I can get the radio group to pass, but not the specific radio (the value). The validating text is under the submit button http://www.hayesbusiness.com.au/workshops_confirm.php if ($_POST['cab2']) { if (!$_POST['cabmky180309']) { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 I can not see that page at my work it has not been catagorized can you post your code so we can help you out. Quote Link to comment Share on other sites More sharing options...
ottz0 Posted March 4, 2009 Author Share Posted March 4, 2009 <form id="form1" method="post" action="workshops_confirm.php"> <table width="100%" border="0" cellspacing="5" cellpadding="8"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><strong>Airlie Beach - 17 March 2009 6pm – 8pm </strong></td> </tr> <tr> <td>Reef Gateway Hotel</td> </tr> </table></td> <td align="center" valign="top"><input name="cab" type="radio" class="radio" id="cab" value="cababh170309" /></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><strong>Mackay - 18 March 2009 6pm – 8pm</strong></td> </tr> <tr> <td>Ocean International Hotel</td> </tr> </table></td> <td align="center" valign="top"><input name="cab" type="radio" class="radio" value="cabmky180309" id="cab" /></td> </tr> <tr> <td><table width="94%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><strong>Moranbah - 24 March 2009 6 – 8pm</strong></td> </tr> <tr> <td>Moranbah Community Centre</td> </tr> </table></td> <td align="center" valign="top"><input name="cab" type="radio" class="radio" id="cab" value="cabmbh240309" /></td> </tr> <tr> <td> </td> <td align="center"> </td> </tr> <tr> <td><strong>How many Tickets would you like?</strong></td> <td align="center"><label> <select name="tickets" id="tickets"> <option value="1 Ticket. The total cost is $44.00" selected="selected">1</option> <option value="2 Tickets. The total cost is $88.00" >2</option> <option value="3 Tickets. The total cost is $132.00" >3</option> <option value="4 Tickets. The total cost is $176.00" >4</option> <option value="5 Tickets. The total cost is $220.00" >5</option> <option value="6 Tickets. The total cost is $264.00" >6</option> <option value="7 Tickets. The total cost is $308.00" >7</option> <option value="8 Tickets. The total cost is $352.00" >8</option> <option value="9 Tickets. The total cost is $396.00" >9</option> <option value="10 Tickets. The total cost is $440.00" >10</option> </select> </label></td> </tr> <tr> <td><input name="txtOption3" type="hidden" id="txtOption3" value="Considering a Business Seminar" /></td> <td align="center"><input type="image" class="radio" id="noborder" src="images/book_online.jpg" alt="Submit" border="0" /></td> </tr> </table> <p><br /> </p> <p></p> </form> ---------------------------------------------------------------------------------------- PHP Code <?php if ($_POST['cab']) { if (!$_POST['cabmky180309']) { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } ?> ------------------------------------------------------------- I am just trying to get it to do the if at the moment Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 Alright I am just throwing this out there, not sure if it is exactly what you are getting at. Your Radio has a preset value, so of course you are going to get that value unless the user choses some thing else but you have no options. The options that you think you have is your select menu, but that will post as $_POST['tickets'] . Because a select is different from a radio and the name of that select is tickets. I think this is the changing value that you are trying to check for. I hope that helps. Quote Link to comment Share on other sites More sharing options...
ottz0 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi Thanks for your help. No I'm getting the values for tickets ok. My radio group is called cab, which is considering a business seminar. but there are 3 dates that i need for CAB which I have set the values for in the radios, the values being the dates. I can get cab to pass with the if statment but not the radios is it's the value of it that I need. It's like i'm 1 level out. I need to write something like if the value of CAB = cabmbh240309 then "Thank you for choosing Considering a business, Airlie Beach on the 24th March 2009" etc etc, This should then set up the rest of the seminars for the diffent dates down the page. So when the user is selecting a radio from a seminar and the date 100409 I am now trying to pass this to say. Thank you for choosing (CAB) Considering a business seminar on the (100409) on the 10th of April 2009. Hope ,this makes sense Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 ok now I understand and I seefully your script. Write it like this. <?php if ($_POST['cab']) { if ($_POST['cab']==='cabmky180309') { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } ?> Hope that solves your problem. Quote Link to comment Share on other sites More sharing options...
T-Bird Posted March 4, 2009 Share Posted March 4, 2009 The form returns the VALUE of the selected radio button under the NAME of the radio element. So <?php if ($_POST['cab']) { if (!$_POST['cabmky180309']) { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } ?> Is not valid because no $_POST['cabmky180309'] was defined. The value of the radio button (in this case the string "cabmky180309") is returned as the value of the post variable $_POST['cab']. Thus <?php if ($_POST['cab'] == 'cabmky180309']) { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } ?> Should work. Quote Link to comment Share on other sites More sharing options...
ottz0 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi thanks Yes, thought that was the case. yours looks correct I can just add the rest on. the code you wrote was returning an error Parse error: syntax error, unexpected ']' in /home/hayesbus/public_html/workshops_confirm.php on line 51 Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 <?php if ($_POST['cab'] == 'cabmky180309') { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it! "; } } ?> Quote Link to comment Share on other sites More sharing options...
ottz0 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi Getting another error Parse error: syntax error, unexpected '}' in /home/hayesbus/public_html/workshops_confirm.php on line 57 Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 <?php if ($_POST['cab'] == 'cabmky180309') { echo "You have chosen Considering a business on 18/03/09"; } else { echo "not it!"; } ?> Quote Link to comment Share on other sites More sharing options...
ottz0 Posted March 4, 2009 Author Share Posted March 4, 2009 cool man thanks heaps. Is it possible you might do this sort of stuff like this for cash as we have a few things like this coming up. As you can see i'm not too good at this. you freelance? work for a company? my email is email@curiousconcepts if you want to get in touch thanks Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 4, 2009 Share Posted March 4, 2009 Please mark this as solved. Check your email. Quote Link to comment 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.