Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    884
    Thanks
    53
    Thanked 6 Times in 5 Posts

    javascript database

    I realise this is out on the edge, but does anyone know of a method to store the answers to, say, a multiple choice quiz in a database?

    If a user logs in to a site - username and PW - could that login be used to save his/her answers discreetly to the database?
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #2
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Not sure what you mean by "out on the edge" but storing data (quiz answers etc etc etc) is a very common task and is the general concept behind all database (dynamic) driven websites.

    Storing/retrieving data in a database is done server side and so you'll need a server side language like PHP, ASP, Java and not javascript which is a client side language.

    Basically, when a user logs in you store their userID in a session variable. You then givem them a html form with the quiz qustions. When they click the form's submit button, their answers are sent to a server side script which first validates and santises the form data before using sql commands via the server side language to store the sent form data in a database table(s) and link it to the userID.
    Last edited by minder; 11-18-2012 at 09:24 AM.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,313
    Thanks
    203
    Thanked 2,564 Times in 2,542 Posts
    Quote Originally Posted by tpeck View Post
    If a user logs in to a site - username and PW - could that login be used to save his/her answers discreetly to the database?
    If "discreetly" means covertly or clandestinely or surreptitiously then I think there is a moral issue to consider.

    It is your responsibility to die() if necessary….. - PHP Manual

    .

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    884
    Thanks
    53
    Thanked 6 Times in 5 Posts
    By 'out on the edge' I meant very difficult to achieve, not wrong!

    And by 'discreet' I meant saved such that one's answers were not made available to others.

    I will check out the non-javascript options.

    Thanks!
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •