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.