nick.moult Posted October 12, 2007 Share Posted October 12, 2007 HI All, I recently posted a problem I had about checking whether radio buttons had been clicked or not when a questionaire was being completed. This was in order to return a message to the user saying "question 2 not completed" for instance. With a bit of help I got that working fine, but now, when that page reloads, the remaining buttons that had been clicked are returned as blank, which means the user will have to fill them all out again - a little annoying! So if anyone can help, please do! Here's the important part of the code: if (hasSurveyBeenCompleted ($connection, $user_id)) { header("location: surveyCompleted.php"); } //this branch is only triggered once submit has been pressed and the page "re runs" itself. if (isset($_POST['submit'])) { if (!isset($_POST["questionOne"])){ echo "you didn't fill question 1 out!"; } else if (!isset($_POST["questionTwo"])){ echo "you didn't fill question 2 out!"; } else { $questionOne = $_POST["questionOne"]; $query = "INSERT into sms.new_survey (answerid, user_id , question_one) Values ($council_id, $user_id, $questionOne);"; pg_exec($connection, $query); // All is good - write info to database and go to main surveys page header("location: options.php"); } } ?><html> <head> <title>User Info</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="global.css" type="text/css"> </head> <body class="bg" style="margin:20px;"> <form action="<? echo $_SERVER['PHP_SELF']; ?>" name="userinfoform" method="POST"> <h2><p>Please enter the appropriate responses and then click on the submit button:</p></h2> <span style="color:#FF0000"></span> <br> <br/> <table width="603" border="0"> <tr> <td colspan = 9>1. Are company x complying with your original and ongoing brief?</td> </tr> <tr> <td><input type="radio" name="questionOne" value="1">1<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="2">2<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="3">3<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="4">4<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="5">5<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="6">6<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="7">7<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="8">8<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionOne" value="9">9<span style="color:#FF0000"></span> </td> </tr> <tr> <td><br/></td> </tr> <tr> <td colspan = 9>2. Are company X meeting their deadlines on time?</td> </tr> <tr> <td><input type="radio" name="questionTwo" value="1">1<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="2">2<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="3">3<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="4">4<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="5">5<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="6">6<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="7">7<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="8">8<span style="color:#FF0000"></span> </td> <td><input type="radio" name="questionTwo" value="9">9<span style="color:#FF0000"></span> </td> </tr> <tr> <td colspan = 9><input name="submit" type="submit" value="Submit"></td> </tr> </table> </form> </body> </html> so to reitterate - If the user doesn't click button 2, he gets a page returned to him saying "you didn't answer question 2" (that part works so far) and question one retains his original selection......(this doesn't work yet and this is where i need the help!) Thanks! ??? Quote Link to comment https://forums.phpfreaks.com/topic/72932-radio-buttons/ 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.