thephoneguy Posted May 25, 2008 Share Posted May 25, 2008 Ok heres my codes messy i know ;p still in learning phase <?php $qid = "Quiz ID-00"; ?> <html> <head> <title><? echo "cheatengine hehe $qid"; ?></title> <style type="text/css"> .style2 { width: 275px; } .style3 { width: 485px; } .style8 { width: 176px; } </style> </head> <body> <h3><? echo "cheatengine fuh $qid"; ?></h3> <form action="results.php" method="post"> <p> Rate on a Scale of 1-5 how each of these questions make you feel.</p> <p> Your Name: <input type="text" name="name"></p> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Questions or little tidbit of words here</td> <td> 1 2 3 4 5 </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="01" name="Q1" type="radio" value="1" /> <input id="02" name="Q1" type="radio" value="2" /> <input id="03" name="Q1" type="radio" value="3" /> <input id="04" name="Q1" type="radio" value="4" /> <input id="05" name="Q1" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td> <input id="1" name="Q2" type="radio" value="1" /> <input id="2" name="Q2" type="radio" value="2" /> <input id="3" name="Q2" type="radio" value="3" /> <input id="4" name="Q2" type="radio" value="4" /> <input id="5" name="Q2" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="6" name="Q3" type="radio" value="1" /> <input id="7" name="Q3" type="radio" value="2" /> <input id="8" name="Q3" type="radio" value="3" /> <input id="9" name="Q3" type="radio" value="4" /> <input id="10" name="Q3" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td> <input id="Radio11" name="Q4" type="radio" value="1" /> <input id="Radio12" name="Q4" type="radio" value="2" /> <input id="Radio13" name="Q4" type="radio" value="3" /> <input id="Radio14" name="Q4" type="radio" value="4" /> <input id="Radio15" name="Q4" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio16" name="Q5" type="radio" value="1" /> <input id="Radio17" name="Q5" type="radio" value="2" /> <input id="Radio18" name="Q5" type="radio" value="3" /> <input id="Radio19" name="Q5" type="radio" value="4" /> <input id="Radio20" name="Q5" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio21" name="Q6" type="radio" value="1" /> <input id="Radio22" name="Q6" type="radio" value="2" /> <input id="Radio23" name="Q6" type="radio" value="3" /> <input id="Radio24" name="Q6" type="radio" value="4" /> <input id="Radio25" name="Q6" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td> <input id="Radio26" name="Q7" type="radio" value="1" /> <input id="Radio27" name="Q7" type="radio" value="2" /> <input id="Radio28" name="Q7" type="radio" value="3" /> <input id="Radio29" name="Q7" type="radio" value="4" /> <input id="Radio30" name="Q7" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio31" name="Q8" type="radio" value="1" /> <input id="Radio32" name="Q8" type="radio" value="2" /> <input id="Radio33" name="Q8" type="radio" value="3" /> <input id="Radio34" name="Q8" type="radio" value="4" /> <input id="Radio35" name="Q8" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio36" name="Q9" type="radio" value="1" /> <input id="Radio37" name="Q9" type="radio" value="2" /> <input id="Radio38" name="Q9" type="radio" value="3" /> <input id="Radio39" name="Q9" type="radio" value="4" /> <input id="Radio40" name="Q9" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td> <input id="Radio41" name="Q10" type="radio" value="1" /> <input id="Radio42" name="Q10" type="radio" value="2" /> <input id="Radio43" name="Q10" type="radio" value="3" /> <input id="Radio44" name="Q10" type="radio" value="4" /> <input id="Radio45" name="Q10" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio46" name="Q11" type="radio" value="1" /> <input id="Radio47" name="Q11" type="radio" value="2" /> <input id="Radio48" name="Q11" type="radio" value="3" /> <input id="Radio49" name="Q11" type="radio" value="4" /> <input id="Radio50" name="Q11" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio51" name="Q12" type="radio" value="1" /> <input id="Radio52" name="Q12" type="radio" value="2" /> <input id="Radio53" name="Q12" type="radio" value="3" /> <input id="Radio54" name="Q12" type="radio" value="4" /> <input id="Radio55" name="Q12" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td> <input id="Radio56" name="Q13" type="radio" value="1" /> <input id="Radio57" name="Q13" type="radio" value="2" /> <input id="Radio58" name="Q13" type="radio" value="3" /> <input id="Radio59" name="Q13" type="radio" value="4" /> <input id="Radio60" name="Q13" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio61" name="Q14" type="radio" value="1" /> <input id="Radio62" name="Q14" type="radio" value="2" /> <input id="Radio63" name="Q14" type="radio" value="3" /> <input id="Radio64" name="Q14" type="radio" value="4" /> <input id="Radio65" name="Q14" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td> <input id="Radio66" name="Q15" type="radio" value="1" /> <input id="Radio67" name="Q15" type="radio" value="2" /> <input id="Radio68" name="Q15" type="radio" value="3" /> <input id="Radio69" name="Q15" type="radio" value="4" /> <input id="Radio70" name="Q15" type="radio" value="5" /> </td> </tr> </table> <table cellpadding="0" cellspacing="0" class="style3"> <tr> <td class="style8"> Question</td> <td class="style2"> <input id="Radio71" name="Q16" type="radio" value="1" /> <input id="Radio72" name="Q16" type="radio" value="2" /> <input id="Radio73" name="Q16" type="radio" value="3" /> <input id="Radio74" name="Q16" type="radio" value="4" /> <input id="Radio75" name="Q16" type="radio" value="5" /> </td> </tr> <tr> <td class="style8"> Question</td> <td class="style2"> <input id="Radio76" name="Q17" type="radio" value="1" /> <input id="Radio77" name="Q17" type="radio" value="2" /> <input id="Radio78" name="Q17" type="radio" value="3" /> <input id="Radio79" name="Q17" type="radio" value="4" /> <input id="Radio80" name="Q17" type="radio" value="5" /> </td> <td> </td> </tr> </tr> <tr> <td class="style8"> Question</td> <td class="style2"> <input id="Radio81" name="Q18" type="radio" value="1" /> <input id="Radio82" name="Q18" type="radio" value="2" /> <input id="Radio83" name="Q18" type="radio" value="3" /> <input id="Radio84" name="Q18" type="radio" value="4" /> <input id="Radio85" name="Q18" type="radio" value="5" /> </td> <td> </td> </tr> </tr> <tr> <td class="style8"> Question</td> <td class="style2"> <input id="Radio86" name="Q19" type="radio" value="1" /> <input id="Radio87" name="Q19" type="radio" value="2" /> <input id="Radio88" name="Q19" type="radio" value="3" /> <input id="Radio89" name="Q19" type="radio" value="4" /> <input id="Radio90" name="Q19" type="radio" value="5" /> </td> <td> </td> </tr> </tr> <tr> <td class="style8"> Question</td> <td class="style2"> <input id="Radio91" name="Q20" type="radio" value="1" /> <input id="Radio92" name="Q20" type="radio" value="2" /> <input id="Radio93" name="Q20" type="radio" value="3" /> <input id="Radio94" name="Q20" type="radio" value="4" /> <input id="Radio95" name="Q20" type="radio" value="5" /> </td> <td> </td> </tr> </table> <p><input type="submit" name="submit" value="Submit Quiz"></p> <input type="hidden" name="qp" value="quiz00.php"> </form> </body> </html> and the php side that keeps bitching at me for no real reason that i can see i havent even started to put in the operators yet. this is just a simple eot( echo on crack ) and it keeps giving me blank page HELP PLZ im sure its something dumb <?php $title = "Quiz Results"; echo "<title>$title</title>"; // Below gets the answers from the page before // if (isset ($_POST['submit'])) { $name = $_POST['name']; $Q1 = $_POST['Q1']; $Q2 = $_POST['Q2']; $Q3 = $_POST['Q3']; $Q4 = $_POST['Q4']; $Q5 = $_POST['Q5']; $Q6 = $_POST['Q6']; $Q7 = $_POST['Q7']; $Q8 = $_POST['Q8']; $Q9 = $_POST['Q9']; $Q10 = $_POST['Q10']; $Q11 = $_POST['Q11']; $Q12 = $_POST['Q12']; $Q13 = $_POST['Q13']; $Q14 = $_POST['Q14']; $Q15 = $_POST['Q15']; $Q16 = $_POST['Q16']; $Q17 = $_POST['Q17']; $Q18 = $_POST['Q18']; $Q19 = $_POST['Q19']; $Q20 = $_POST['Q20']; $qp = $_POST['qp']; } // Below checks to see if you forgot anything // if ($name == "") { die ("Please insert name."); } if ($Q1 == "") { die ("you forgot to fill in question 1"); } if ($q2 == "") { die ("you forgot to fill in question 2"); } if ($q3 == "") { die ("you forgot to fill in question 3"); } if ($q4 == "") { die ("you forgot to fill in question 4"); } if ($q5 == "") { die ("you forgot to fill in question 5"); if ($q6 == "") { die ("you forgot to fill in question 6"); if ($q7 == "") { die ("you forgot to fill in question 7"); if ($q8 == "") { die ("you forgot to fill in question 8"); if ($q9 == "") { die ("you forgot to fill in question 9"); if ($q10 == "") { die ("you forgot to fill in question 10"); if ($q11 == "") { die ("you forgot to fill in question 11"); if ($q12 == "") { die ("you forgot to fill in question 12"); if ($q13 == "") { die ("you forgot to fill in question 13"); if ($q14 == "") { die ("you forgot to fill in question 14"); if ($q15 == "") { die ("you forgot to fill in question 15"); if ($q16 == "") { die ("you forgot to fill in question 16"); if ($q17 == "") { die ("you forgot to fill in question 17"); if ($q18 == "") { die ("you forgot to fill in question 18"); if ($q19 == "") { die ("you forgot to fill in question 19"); if ($q20 == "") { die ("you forgot to fill in question 20"); } // Below is where the answers are actually displayed // { echo<<<EOT <p>Results: $name<br> 1.) $q1<br> 2.) $q2<br> 3.) $q3<br> 4.) $q4<br> 5.) $q5<br> 6.) $q6<br> 7.) $q7<br> 8.) $q8<br> 9.) $q9<br> 10.) $q10<br> 11.) $q11<br> 12.) $q12<br> 13.) $q13<br> 14.) $q14<br> 15.) $q15<br> 16.) $q16<br> 17.) $q17<br> 18.) $q18<br> 19.) $q19<br> 20.) $q20</p> EOT; } ?> Please dont flame i know its shit but its my first crack at php so give me a break Quote Link to comment Share on other sites More sharing options...
Wolphie Posted May 25, 2008 Share Posted May 25, 2008 How are you checking to see if the answers are even correct? Quote Link to comment Share on other sites More sharing options...
thephoneguy Posted May 25, 2008 Author Share Posted May 25, 2008 im not right now i just want it to spit out values. its not a test per say its how do you feel about this rate 1-5. based on that i will add up the numbers then display a custom message for each group ie. 0-20//21-40//41-60//61-80//81-100. i think i can figure that part out i just am wondering really why its not spitting it back to me. Quote Link to comment Share on other sites More sharing options...
Wolphie Posted May 25, 2008 Share Posted May 25, 2008 Download jQuery from here for some AJAX. Place it in the same folder as you're developing. Basic example: <html> <head> <title>Quiz!</title> <script type="text/javascript" src="jquery.js"></script>' <script type="text/javascript"> $(function() { // Checks if the DOM is ready to be manipulated. $('form').submit(function(){ // Adds a submit handler to the form. $.ajax({ // Begins the call. type: 'POST', // Specifies the type of request. url: 'results.php', // URL to make the request to. data: { q1: $('input[name=q1]:checked').val() }, // Data to be sent. dataType: 'html', // Format in which data is returned error: function() { / If an error occurs display an alert. alert("An errorhas occurred, please try again."); }, success: function(data) { // If successful. $('div#quiz').empty(); // Empty the contents of the DIV, including form. $('div#quiz').html(data); // Replace the HTML of the DIV with the results. }, complete: function() { // If complete. $('div#quiz').fadeIn('slow'); // Fade in the DIV slowly. } }); }); return false; // IMPORTANT! Must be returned FALSE, otherwise page will refresh! }); </script> </head> <body> <div id="quiz"> <form method="post"> <table> <tr><td>Name</td></tr> <tr><td><input type="text" name="name" id="name" /></td></tr> <tr><td>Question 1</td></tr> <tr> <td><input type="radio" name="q1" id="a1" value="1" checked="yes"><label for="a1">Answer 1</label></td> <td><input type="radio" name="q1" id="a2" value="2" /><label for="a2">Answer 2</label></td> <td><input type="radio" name="q1" id="a3" value="3" /><label for="a3">Answer 3</label></td> </tr> <tr><td><input type="submit" name="submit" value="submit" /></td></tr> </table> </form> </div> </body> </html> results.php <?php error_reporting('E_ALL'); $name = (isset($_POST['name'])) ? htmlentities(htmlspecialchars($_POST['name'])) : false; // Check if NAME is set, and secure. $q1 = (isset($_POST['q1'])) ? $_POST['q1'] : false; if($name) { print '<p>' . $name . '</p>'; if($q1 == 3) // Answer is supposed to be 3. print '<p>Question 1: Correct!</p>'; else print '<p>Question 1: In-Correct!</p>'; // Note: You don't need curly braces for 1 line blocks. } else { print '<p>Please enter your name.</p>'; print '<p><a href="index.php">Go Back</a>.</p>'; } ?> Although you don't need to use AJAX or jQuery. It might not work, but it's 8am and I haven't slept yet. Quote Link to comment Share on other sites More sharing options...
Wolphie Posted May 25, 2008 Share Posted May 25, 2008 By the way, it should be like this: <?php $line = array('name' => 'Wolphie', 'Age' => '19'); echo <<<EOT Name: {$line['name']} Age: {$line['age']} EOT; ?> For multiple lines and in-line variables use: <?php $name = 'Wolphie'; echo <<<END This is a paragraph that has multiple lines. My name is $name END; ?> Quote Link to comment Share on other sites More sharing options...
thephoneguy Posted May 25, 2008 Author Share Posted May 25, 2008 Thanks wolfie. But thats not exactly what im looking for . i will remember that for future reference though . Quote Link to comment Share on other sites More sharing options...
thephoneguy Posted May 25, 2008 Author Share Posted May 25, 2008 Really all i am wandering is why am i getting a white screen when i click submit and score. results.php is messing up 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.