Comunitatea PHP Romania
MightyDeals

Prima pagină Web HTML/JavaScript/CSS mysql voting

mysql voting

Aici postaţi orice este legat de tehnologiile "client side". HTML, HTML5, XHTML, CSS, CSS3, XML, Standarde
Manual JS: http://www.phpromania.net/jsmanual/index.html

Mesaj Lun Apr 16, 2012 2:14 pm
CaTaLinU Average Member

Mesaje: 58
nu ma pricep la asa ceva ...
care ma poate ajuta cu un script de voturi

baza de date:
id nume voturi
1 Catalin 10
2 Altcnv 23

ceva de genu si cand da acea persoana un vot , sa creasca si numarul din baza de date...... si sa aiba voie odata la 24 ore ..

multumesc mult

Mesaj Lun Apr 16, 2012 6:22 pm
keen Senior Member

Mesaje: 253
Localitate: Br?ila

Ce trebuie modificat, modifici tu :)

<?php
session_start();

if(isset($_COOKIE['voted']){
   $_SESSION['voted'] = $_COOKIE['voted'];
  }
 
if(isset($_GET['id'])) $id=$_GET['id']; else $id=false;

if($id)
{
   if(isset($_SESSION['voted']))
   header("location: ".$_SERVER['PHP_SELF']);
   else
   {
$currentvotes=mysql_fetch_array(mysql_query("select votes from pols where id='".$id."'"));
$newvotes=$currentvotes[0]+1;
mysql_query("update pols set votes='".$newvotes."' where id='".$id."'");

$_SESSION['voted'] = time();
setcookie("cookvoted", $_SESSION['voted'], time()+60*60*24*100, "/");

header("location: ".$_SERVER['PHP_SELF']);
}
}
else
{
$sql=mysql_query("select * from pols order by name ASC");
while($row=mysql_fetch_array($sql)):

$nr = mysql_fetch_array(mysql_query("select count(*) from pols"));
print $row['name']." - ".$row['votes']." => <a href='".$_SERVER['PHP_SELF']."?id=".$row['id']."' title='Vote ".$row['name']."'>Vote ".$row['name']."</a><br>";

endwhile;
}

Mesaj Dum Apr 14, 2013 12:55 am
Google Bot New Member

Mesaje: 1

Înapoi la HTML/JavaScript/CSS

Copyright © 2001-2013 PHP Romania Gazduire web | Haine online | Gazduire web | Campanii SMS | Gazduire Claus Web | Inregistrare Domenii | Anunturi | Jocuri cu bile
Furnizat de phpBB® Forum Software © phpBB Group
Translation/Traducere: phpBB România
Powered by Simplis