|
-
Apr 7th, 2005, 11:41 AM
#1
Thread Starter
Frenzied Member
Create a Poll
How can you create a simple poll in an HTML page?
Here is a basic bit of HTML with the poll on it, but I am not sure what should I do to store/display results.
Code:
<HTML>
<HEAD>
<TITLE>HTML 4.01 Transitional</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</HEAD>
<BODY>
<FORM>
<P>What do you think?</P>
<P>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="Value1" CHECKED="CHECKED">The canteen charges too much<BR>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="Value2">The canteen is good value for money<BR>
<INPUT TYPE="SUBMIT" NAME="OK"></P></FORM> </BODY>
</HTML>
Last edited by agmorgan; Apr 7th, 2005 at 01:04 PM.
-
Apr 7th, 2005, 12:07 PM
#2
Fanatic Member
Re: Create a Poll
You need to store the results in either a database or a textfile.
-
Apr 7th, 2005, 12:09 PM
#3
Hyperactive Member
Re: Create a Poll
does your server support php?
If there is only one perfect person in the universe, does that make them imperfect?
-
Apr 7th, 2005, 12:32 PM
#4
Thread Starter
Frenzied Member
Re: Create a Poll
I would probably store the results in a text file as it is easier and there wont be much data.
php is supported, but I have never done any before
-
Apr 7th, 2005, 01:03 PM
#5
Thread Starter
Frenzied Member
Re: Create a Poll
OK a quick search for free php poll came up with Advanced Poll v2.03 http://proxy2.de/scripts.php
Time to get my hands dirty!
-
Apr 7th, 2005, 01:26 PM
#6
Fanatic Member
Re: Create a Poll
Good luck.
-
Apr 8th, 2005, 07:28 AM
#7
Hyperactive Member
Re: Create a Poll
why dont you make your own php script. normally anything that is free has a logo on it and loads of copyright text on the main page and links offsite.this is a little php script that appends to poll.txt with what ever was sent from the other page. you can add a script to redirect the browser to another page if you want.
PHP Code:
<?
$URL = $_POST["name"];
fwrite(fopen("poll.txt","a"), $URL . "\n");
fclose(fopen("poll.txt","a"));
print
'<html>
<head>
<title>Dans Web Server 2005!</title>
</head>
<body>
<p>' . $URL . '</p>
</body>
</html>'
?>
hope this helps but i just seen what you are trying to save and i dont know how to save that. maybe spend a while with my script but that is the kind of script you want to play around with
Last edited by dandono; Apr 8th, 2005 at 07:33 AM.
If there is only one perfect person in the universe, does that make them imperfect?
-
Jul 17th, 2005, 06:01 AM
#8
Hyperactive Member
Re: Create a Poll
Your HTML for the form is not done correct
HTML Code:
<FORM>
<P>What do you think?</P>
<P>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="Value1" CHECKED="CHECKED">The canteen charges too much<BR>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="Value2">The canteen is good value for money<BR>
<INPUT TYPE="SUBMIT" NAME="OK"></P></FORM> </BODY>
It should be:
HTML Code:
<form name="input" action="phpfile.php"
method="get">
<P>What do you think?</P>
<P>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="1" CHECKED="CHECKED">The canteen charges too much<BR>
<INPUT TYPE="RADIO" NAME="Radio1" VALUE="2">The canteen is good value for money<BR>
<INPUT TYPE="SUBMIT" NAME="OK"></P></FORM> </BODY>
</form>
This is a simple php script to save the poll.
PHP Code:
<?php
$file = $_GET['Radio1'];
$filename = $file . ".txt";
$handle = fopen($filename, "r");
$count = fread($handle, filesize($filename));
fclose($handle);
$ncount = $count + 1;
fwrite(fopen($file,"w"), $ncount);
fclose(fopen($file,"w"));
?>
I think it works but i have not tested it because my server is a bit broken.
This is the script needed to read the poll (simple text only).
PHP Code:
<?php
$filename = "1.txt";
$handle = fopen($filename, "r");
$str1 = fread($handle, filesize($filename));
fclose($handle);
$filename = "2.txt";
$handle = fopen($filename, "r");
$str2 = fread($handle, filesize($filename));
fclose($handle);
echo "Canteen Charges too much: " . $str1 . "<br>Canteen is good value:" . $str2;
?>
If there is only one perfect person in the universe, does that make them imperfect?
-
Jul 22nd, 2005, 02:21 AM
#9
Hyperactive Member
Re: Create a Poll
with that php code though u ahve to make sure the name of ur textfile matches the name for $filename or else it will not work.
-
Jul 23rd, 2005, 05:59 AM
#10
Hyperactive Member
Re: Create a Poll
it is only a basic one that i just coded on the fly. to make one that will work all the time and will not fail easily would take a couple of hours.
If there is only one perfect person in the universe, does that make them imperfect?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|