By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,985 Members | 1,694 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,985 IT Pros & Developers. It's quick & easy.

creating a poll using user input

P: 25
OK so pretty close to a beginner here so sorry if this sounds really basic or dumb.

I'm trying to create a simple "poll" which allows users to add options to the poll in addition to voting on the options already presented to them.

I obviously don't expect someone to give me code, but can you point me which direction I should be looking at? How would you, broadly speaking, go about doing this?

I am a fast learner but going from nothing I am at a loss as to where to start.
Nov 28 '11 #1

✓ answered by dlite922

I was once in your place, and replies to go learn a language didn't help. So assuming you're capable of learning the code, here are the steps to do that (there are multiple ways of doing such a thing, some are better than others for different reasons)

1. Create a data "place". This could be a database mysql), or a regular text file, or an XML file. Just somewhere you could store the question, its options, and votes for those options.

2. Create a script (using PHP or ASP) to read, insert, update and delete records from the data source above.

3. Create an HTML form that presents the user with the question and its options, along with a text field as the last option to write themselves. If you can only choose one option, I would use radio buttons.

4. Submit the form to your script and collect the data. If the text field is filled, add the option to the question record using your script and count the vote as 1. (since he voted for that). If he chose another predefined option, using your script grab the current vote count add one, and save it back.

5. You could present the current results of the poll to the user in a new HTML (new page, new PHP script) or you could just post a simple thank you message.

Once that works, you can add enhancements, such as not crashing when multiple people vote at the same time, ensuring a person only votes once, and preventing duplicate options (i.e. someone could misspell "Fo0o" and create a new option when he just meant to vote for the existing option "Foo").

Welcome to programming(scripting),


Dan

Share this Question
Share on Google+
3 Replies


omerbutt
100+
P: 638
hi akristof,
you need to have know how about HTML, CLIENTSIDE SCRIPT(javascript) and a SERVER SIDE SCRIPT (php , asp )language, how much beginner you are , ?, go here to find out about these 3 here.
regards,
Omer Aslam
Nov 28 '11 #2

dlite922
Expert 100+
P: 1,584
I was once in your place, and replies to go learn a language didn't help. So assuming you're capable of learning the code, here are the steps to do that (there are multiple ways of doing such a thing, some are better than others for different reasons)

1. Create a data "place". This could be a database mysql), or a regular text file, or an XML file. Just somewhere you could store the question, its options, and votes for those options.

2. Create a script (using PHP or ASP) to read, insert, update and delete records from the data source above.

3. Create an HTML form that presents the user with the question and its options, along with a text field as the last option to write themselves. If you can only choose one option, I would use radio buttons.

4. Submit the form to your script and collect the data. If the text field is filled, add the option to the question record using your script and count the vote as 1. (since he voted for that). If he chose another predefined option, using your script grab the current vote count add one, and save it back.

5. You could present the current results of the poll to the user in a new HTML (new page, new PHP script) or you could just post a simple thank you message.

Once that works, you can add enhancements, such as not crashing when multiple people vote at the same time, ensuring a person only votes once, and preventing duplicate options (i.e. someone could misspell "Fo0o" and create a new option when he just meant to vote for the existing option "Foo").

Welcome to programming(scripting),


Dan
Nov 28 '11 #3

P: 25
Thanks Dan that's very helpful!
Nov 29 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.