oriental_express Posted October 31, 2008 Share Posted October 31, 2008 Hi there I am in my final year doing my dissertation. I would like to know if it is possible to build a php questionnaire eg Q1 blah blah blah opt A,B,C. Based on what is submitted I would like it to return a "reply / report " that based on these answers , this is what I think you should do. So in sense its like a diagnosis and heres your possible answer / solution. Most php questionnaire that I have found just give you results on what has been submitted which turns into graphs. What I need is something that replies with a "solution" I would like to know if such a thing is possible and where would be a good place to start. Thank you for your time Michael Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/ Share on other sites More sharing options...
Flames Posted October 31, 2008 Share Posted October 31, 2008 im not giving you any code, but ill tell you what you need to do. Make a html form, using radio buttons (or checkboxes for multiple answers, possibly use drop downs but not as tidy), each question needs a unique id e.g. q1 and each answer needs a value like a,b,c... put a submit button that works into a php page which gets the results of the user (post method is probably better), and using if statements check if each answer is right. e.g. if($_POST['q1'] == "a") {$q1 = "correct"; }else{ $q1 = "wrong"; $q1message = "You selected this answer"; $q1message2 = $_POST['q1']; $q1message3 "The right answer was cheese is good"; //could simply use echo if your not fussed about layouting } then further on simply check if it is right or wrong and echo the message in your desired layout Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-679550 Share on other sites More sharing options...
oriental_express Posted October 31, 2008 Author Share Posted October 31, 2008 Hi there thanks for reply I think im ok with creating html layouts. I should have been more clear. I would like to know if its possible to give some sort of "report" Based on the reply to all questions. That could be perhaps displayed on a new page / or sent to email. eg Q1 what is your experience ......... a/b/c if c is chosen Q2 Do you understand HTML a = NO b= Yes if a was chosen the newly displayed page / sent to email would say "OK you need to do this " Basically the survey is really a diganosis. Based on all the answers a report will be newly displayed (which I will design) or is sent to email. Is this clear ? Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-679695 Share on other sites More sharing options...
Flames Posted October 31, 2008 Share Posted October 31, 2008 just put if statements inside each other so (again radio buttons id's as before) q1 what is your experience a. none b. some c. a lot q2 do you understand HTML a. no b. yes c. slightly then for the php $q1 = $_POST['q1']; $q2 = $_POST['q2']; if($q1 == "b") { if($q2 == "a") { echo "You have a lot of experience but don\'t understand HTML, you need to read a HTML tutorial"; } elseif($q2 == "b") { echo "You have a lot of experience and understand HTML, you don\'t need to do anything"; } elseif() { } etc } elseif($q1 == "a") { } etc Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-679706 Share on other sites More sharing options...
oriental_express Posted October 31, 2008 Author Share Posted October 31, 2008 just put if statements inside each other so (again radio buttons id's as before) q1 what is your experience a. none b. some c. a lot q2 do you understand HTML a. no b. yes c. slightly then for the php $q1 = $_POST['q1']; $q2 = $_POST['q2']; if($q1 == "b") { if($q2 == "a") { echo "You have a lot of experience but don\'t understand HTML, you need to read a HTML tutorial"; } elseif($q2 == "b") { echo "You have a lot of experience and understand HTML, you don\'t need to do anything"; } elseif() { } etc } elseif($q1 == "a") { } etc Thank you let me have a try with that I'll get back to you Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-679708 Share on other sites More sharing options...
oriental_express Posted November 1, 2008 Author Share Posted November 1, 2008 Hi there Flames I got some code you could look at Do you think this is a good way to do it michael.html <html> <body> <form name="input" action="michael.php" method="post"> <p>Q1. Do you have any experience with HTML ? </p> <p> Yes: <input type="radio" name="html" value="Yes"> <br> No: <input type="radio" name="html" value="No"> <br> Slightly: <input type="radio" name="html" value="Slightly"> <hr> <p>Q2. Do you know how to use control panel (Cpanel) ? </p> <p> Yes: <input type="radio" name="cp" value="Yes"> <br> No: <input type="radio" name="cp" value="No"> <br> Slightly: <input type="radio" name="cp" value="Slightly"> <hr> <input name="submit" type ="submit" value ="Submit"> </p> </form> <p> </p> </body> </html> Michael.PHP <?php $html = $_POST['html']; $cp = $_POST['cp']; if($html == "Yes") { echo "You have a lot of experience but don't understand HTML, you need to read a HTML tutorial <br/><br/>"; } elseif($html == "No") { echo "You have a lot of experience and understand HTML, you don't need to do anything<br/>"; } elseif($html == "Slightly") { echo "You just need to read up abit more on html<br/>"; } if($cp == "Yes") { echo "You dont need to read up on Cpanell<br/>"; } elseif($cp == "No") { echo "You need to read up on cpane asap<br/>"; } elseif($cp == "Slightly") { echo "You just need to touch up on asp<br/>"; } ?> Thank you for reply Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-679819 Share on other sites More sharing options...
Flames Posted November 1, 2008 Share Posted November 1, 2008 that would and should work pretty well (apart from the fact Yes and No on question 1 are the wrong way round), though this would only give you standalone answers (single statement then another single statement), while the method i was explaining was merging the answers by putting an if statement inside another if statement, which then you could have a longer statement Good HTML knowledge and Good cPanel knowledge, or Good HTML knowledge but lacking knowledge to do with the cPanel, practice using the cPanel more. for simplicity use the first option, (single statements), if you have the time then use the second option, but that many if statements will take a lot of time and it will be easier to make a mistakke. Personally i think option 1 is better. Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-680015 Share on other sites More sharing options...
oriental_express Posted November 5, 2008 Author Share Posted November 5, 2008 Thanks again mate ! Link to comment https://forums.phpfreaks.com/topic/130915-solved-php-questionnaire-that-calculates-responses-which-then-replies-with-a-report/#findComment-683171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.