/    Sign up×
Community /Pin to ProfileBookmark

Complex website form

Hi, I’m wondering how I can go about and how difficult it would be to create a form for users which takes them to a specific page based on the combination of answers they give on multiple questions (yes/no answer questions).

It will be similar to this one, but a lot less complex, with fewer questions: [url]https://debtremedy.stepchange.org/quickassessment.aspx[/url].

Here is how I want it to work:

There are 12 different questions, all with the option of yes or no. Once the user has answered all of the questions on the form (which are about personal debt), the website will take them to a page which gives them the appropriate debt advice.

There are 14 different pieces of Debt Advice. Sometimes, depending on how the user answers, all of these pieces of advice will be appropriate and will need to appear on the page which appears after they finish the form. However, if the user answers yes to question 1, this will rule out Debt Advice piece number 5, 8, and 12, and if they answer yes to question 2 then the program will rule out Debt Advice number 2, 7, and 10 (if they answered no then it would not rule these out).

So in this way, the answers they give to the questions will determine the information which will appear on the page that results after they have finished the form.

How would one go about creating/programming such a form?

Any advice or comments would be much appreciated.

Philip

to post a comment
Full-stack Developer

2 Comments(s)

Copy linkTweet thisAlerts:
@jedaisoulOct 12.2013 — Sounds like a job for PHP. Roughly, it would be something like...

<i>
</i>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="iso-8859-1"&gt;
&lt;meta name="description" content=""&gt;
&lt;meta name="keywords" content=""&gt;
&lt;title&gt;Form Test&lt;/title&gt;
&lt;!--
&lt;link href="style.css" rel="stylesheet" type="text/css"&gt;
--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="header"&gt;
&lt;h1&gt;Debt questionnaire&lt;/h1&gt;
&lt;/div&gt;
&lt;?php
if(isset($_POST['submit'])) {

$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
$q3 = $_POST['q3'];
$q4 = $_POST['q4'];
?&gt;
&lt;!-- para 1 --&gt;
&lt;p&gt;
&amp;nbsp;(para 1) Blah, blah, blah&lt;/p&gt;

&lt;!-- para 2 --&gt;
&lt;?php if($q2&lt;&gt;'y') {?&gt;
&lt;p&gt;
&amp;nbsp;(para 2) Blah, blah, blah&lt;/p&gt;
&lt;?php ;} ?&gt;

&lt;!-- para 3 --&gt;
&lt;p&gt;
&amp;nbsp;(para 3) Blah, blah, blah&lt;/p&gt;
&lt;!-- para 4 --&gt;
&lt;p&gt;
&amp;nbsp;(para 4) Blah, blah, blah&lt;/p&gt;

&lt;?php if($q1&lt;&gt;'y') {?&gt;
&lt;!-- para 5 --&gt;
&lt;p&gt;
&amp;nbsp;(para 5) Blah, blah, blah&lt;/p&gt;
&lt;?php ;} ?&gt;

&lt;!-- para 6 --&gt;
&lt;p&gt;
&amp;nbsp;(para 6) Blah, blah, blah&lt;/p&gt;

&lt;form method=POST action="#"&gt;
&lt;input type="submit" value="clear"&gt;
&lt;/form&gt;

&lt;?php ;} else {

$q1 = ' ';
$q2 = ' ';
$q3 = ' ';
$q4 = ' ';

?&gt;

&lt;form method=POST action="#"&gt;
&lt;label&gt;&amp;nbsp; Question 1... &lt;input type="text" name="q1" size="1" maxlength="1" value=" "&gt;&lt;/label&gt;&lt;br&gt;
&lt;label&gt;&amp;nbsp; Question 2... &lt;input type="text" name="q2" size="1" maxlength="1" value=" "&gt;&lt;/label&gt;&lt;br&gt;
&lt;label&gt;&amp;nbsp; Question 3... &lt;input type="text" name="q3" size="1" maxlength="1" value=" "&gt;&lt;/label&gt;&lt;br&gt;
&lt;label&gt;&amp;nbsp; Question 4... &lt;input type="text" name="q4" size="1" maxlength="1" value=" "&gt;&lt;/label&gt;&lt;br&gt;
&lt;br&gt;&lt;input type="submit" name="submit" value="submit"&gt;&lt;br&gt;
&lt;/form&gt;
&lt;?php ;} ?&gt;
&lt;/body&gt;
&lt;/html&gt;



Note: The example has only four questions and six paragraphs of advice, but it should be sufficient to show the idea. Also, there is no validatiion of the input, and it only recognises "y" not "Y". So an actual site would need some tidying up.

The page needs to be called something like "debt.php" (not "debt.html") and must be placed on a server that supports PHP code. It may then be called via a shortcut. e.g. If you are testing it on a local host like Wampserver: "target=http://localhost/debt.php".
Copy linkTweet thisAlerts:
@philipthechilipauthorOct 12.2013 — Thanks a lot for your reply, this is a big help. Much appreciated.

Phil
×

Success!

Help @philipthechilip spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...