Results 1 to 10 of 10

Thread: Create a Poll

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Resolved 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>

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602

    Re: Create a Poll

    You need to store the results in either a database or a textfile.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Create a Poll

    does your server support php?
    If there is only one perfect person in the universe, does that make them imperfect?

  4. #4

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    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

  5. #5

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    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!

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602

    Re: Create a Poll

    Good luck.

    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  7. #7
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    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?

  8. #8
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    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($handlefilesize($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($handlefilesize($filename));
    fclose($handle);
    $filename "2.txt";
    $handle fopen($filename"r");
    $str2 fread($handlefilesize($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?

  9. #9
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    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.

  10. #10
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    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
  •  



Click Here to Expand Forum to Full Width