/    Sign up×
Community /Pin to ProfileBookmark

Check user input

Hello

I was wondering how I can have a page where a user is asked a series of questions using check boxes, input forms or similar – and their input answers are then checked with the correct answer after this they are given a score.

For example:

[Form] What is 2 + 2 ?

[Input box] // IF enters “4” , THEN _ECHO_ ‘You should take Mathematics!’
// IF enters ELSE _ECHO_ ‘You should not take Mathematics’

I would greatly appreciate any help / tutorials / scripts.

Hope my question is clear.

Thanks in advance.?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonFeb 16.2012 — You will want to use an "HTML FORM". After the user enters an answer (or all answers), they click a "submit" button which submits the form's inputs to the server for validation.

Start here: http://myphpform.com/
Copy linkTweet thisAlerts:
@jeffrey83Feb 17.2012 — i think , you should using jquery , it is easy for your problem , Example :


<form action="/yourURL/" method="post" id="check" >

<div style="margin-left: 10px; margin-top: 10px;">

<label>Title</label><br />

<input type="text" name="title" id="title" value="" maxlength="250" class="required" style="width: 200px;" /> <br />

<label>Answer</label><br />
<span id="question" style="color: #FF0000"></span>
<input type="text" name="sercurity" id="sercurity" class="required" style="width: 50px;">
<input type="hidden" name="answer" id="answer" class="required" style="width: 50px;">
<input type="submit" id="submitButton" class="button" value="Save">
</div>

</form>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>

<script>

$(".button").click(function(){
var sercurity = $('#sercurity').val();
var answer = $('#answer').val();
if (sercurity != answer) {
alert('answer is notcorect!');
$('#sercurity').focus();
return false;
}
});
function question() {
var num1 = Math.floor(Math.random()*10);
var num2 = Math.floor(Math.random()*10);
var sum = num1 + num2;
$('#question').html(' = ' + num1 + ' + ' + num2);
$('#answer').attr('value' , sum);
}
question();

</script>
[/QUOTE]


Demo : http://alltour4you.com/form.html
Copy linkTweet thisAlerts:
@mv0010authorFeb 18.2012 — Thanks jeffrey83, I was wondering though what should go in the [b]yourURL[/b] part?
Copy linkTweet thisAlerts:
@mv0010authorFeb 18.2012 — Thanks to nap0leon as well ?
×

Success!

Help @mv0010 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.28,
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,
)...