voting with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

voting with php

Post by 7up »

hi everyone, yes im new to the forum!! is there anyone that can help me with some php code. i have to make a wepage using html and php which does the following

1. present visitors to the website with a multiple-choice question, which allows them to select just one of the answers (i.e, the choice they want to vote for)

2. allow voters to see how others have voted (in terms of percentages voting for each choice), but only after they themselves have voted
The website should not allow visitors to vote more than once (this is done by setting a cookie).

Having the code as a separate html and php file is prefered.

Please help me!!!!!
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

Sounds good, when do you get started?
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

1. present visitors to the website with a multiple-choice question, which allows them to select just one of the answers (i.e, the choice they want to vote for)
This can just be a basic HTML form, but in the line:

Code: Select all

<form action="vote.php" method="post"  enctype="multipart/form-data">
set the action="vote.php" to whatever PHP file you want the results to show up on.

Then on vote.php you can use the variables passed from the form (more info). You can either enter these results into a database (like MySQL) or just into a text file (tutorial).
You will also need to know how to use cookies.
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

xisle, yeh its sound gud but a bitch to do!! gettin started on it now!

DuFF, cheerz, i'll check them notes out! if i hav any problems i'll msg u 2 help me out as ur the only one that's given sum useful info!
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

hello anyone else that can help me??
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

what's the exact problem?

Is it a full script request? Is there a problem with your code? ...?
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

aquila125, its a full script request!!! i spent so much time workin on my macromedia flash mx and now ive only got a small amount of time to do this. If your a pro then this will be minoir for you but im new to this program so i got quite abit to learn. I've also got my c++ program to work on aswell!!! so theres alot of work and i was jus wondering if sum1 can be kind and generous enough to work ths one out for me.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

why not do a search on http://www.hotscripts.com

click here for the search i did http://www.hotscripts.com/cgi-bin/searc ... ng&catid=2

you will definately find some FREE scripts on there

Mark
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

Bech100, thanks for that, the thing thats far too complex from what i need. i only want to operate using html and php and a data(txt) files. No need for MySQL or apache any other database. if you know how to do it then jus do the code im sure its not that long.

cheerz

7up ghetto
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

and for the downloads which are useful on that webpage is says this..."Diese Präsenz ist leider nicht verfügbar." whatever that means!! doesnt let me download it
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Try this: http://www.hotscripts.com/Detailed/6752.html

It's a simple poll with text files used for data handling. You can always edit it if you want. Should take out a large amount of coding time because you're starting with a base.
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

DuFF, thnx for that but wy are there so many files!!! your a programmer cant u make i lil program for me??
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

7up wrote:No need for MySQL or apache any other database...
Just a quick note, apache isn't a database ;)

Mark
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

7up wrote:DuFF, thnx for that but wy are there so many files!!! your a programmer cant u make i lil program for me??
So many files!?

there like 2 php files and a text file + a couple of images. Open the file called README with wordpad, there is full instructions on how to set the script up. It won't take even a novice more than 5-10 mins to be up and running.

Heres the instructions:

4. Installation and Configuration:
==================================

It's a PHP script, so installation is pretty easy.

Copy '*.php', 'poll_data.txt' and 'vote/*' in your good directory.

Change permissions to 'poll_data.txt' for be writing by nobody (chmod a+rw)

Edit 'php_poll.php', you will have to do some configuration:

$RESULT_FILE_NAME = "poll_data.txt";
// En: Absolute path and name to file contain poll data.

$QUESTION = "How do you like this Script?";
// En: Question Text.
$ANSWER = array("Love it!", "Like it!", "Its okay..", "I dislike it", "I hate it..");
// En: All answer.

$IMG_DIR_URL = "./vote";
// En: URL Directory of poll graphs.

$REVOTE_TIME = 3600;
// En: Time (second) after people can revote, use cookies.

You can edit 'test.php' to change look.


5. How to run it ?
==================

go on http://www.hostname.dom/dir/test.php
7up
Forum Newbie
Posts: 18
Joined: Tue Dec 09, 2003 12:47 pm

Post by 7up »

which poll is that from the list???? i'll giv that a try
Post Reply