Simple Online Voting system php--publish poll page

Source: Internet
Author: User
The publishing page is only available when the user is logged in, so check that you are logged in and then allow the poll to be issued.

 
  
  
   
  
   
  • Note: Once published will not be modified!

  • The information entered by the user is posted to the background in post format.

     = $min && $vname = "") {for ($i =1; $i < $itemcount; $i + +) {$j = $i +1; $item = $item. '                * '. @$_post[$j];            $num = $num. ' *0 ';            } $sql 3= "Select uid from users WHERE username= ' $ouser '";            $getVid =mysql_query ($sql 3);            $row =mysql_fetch_row ($getVid);            $uid = $row [0]; $sql = "INSERT into vote (vname,starttime,uid,vintro,open,more,max,min) value (' $vname ', ' $starttime ', ' $uid ', ' $vintro ')            , ' $open ', ' $more ', ' $max ', ' $min ');            mysql_query ($sql);            $sql 2= "Select vid from vote WHERE vname= ' $vname '";            $getVid =mysql_query ($sql 2);            $row =mysql_fetch_row ($getVid);            $vid = $row [0];            $sql 4= "INSERT into Votetitle (vid,itemcount,item,num) value (' $vid ', ' $itemcount ', ' $item ', ' $num ')";            mysql_query ($sql 4);        echo "";        } else{echo "";    }}else{echo ""; }}?>

    1. Check if login

        $ouser =@$_get[' user '];    if ($ouser! = ") {
    2. Get the current time
            $time =time ();        $starttime =date ("y-m-d", $time);
    3. Form the option information and voting statistics that can be saved in the database

       $item =@$_post[1];        $num =0;        if ($max >= $min && $vname! = "") {for            ($i =1; $i < $itemcount; $i + +) {                $j = $i +1;                $item = $item. ' * '. @$_post[$j];                $num = $num. ' *0 ';            }
    (1) Option information and poll statistics are composed of a string by separating the option information with "*"

    Example: "Option one * option two * option three"

    (2) The default initial voting statistics, the items are all 0.

    Example: "0*0*0"

    (3) This loop statement is not necessary, in PHP provides a special method of integrating and decomposing arrays into strings (explode and implode), but in the completion of this part of the code I do not know the application of this method, GU self completed this function.

    The above describes the simple online voting system php--the release of the voting page, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.