Cod: Selectaţi tot
<?php
$fata=$_GET['fata'];
// Connect to server and select database.
mysql_connect("localhost", "root", "")or die("cannot connect");
mysql_select_db("voturi_fete")or die("cannot select DB");
$puncte="+";
// update data in mysql database
$sql="UPDATE poze_fete SET voturi= voturi + 1 WHERE id= '$fata'";
$result=mysql_query($sql);
$ip = $_SERVER['REMOTE_ADDR'];
$sql2="INSERT INTO voturi (ip, poza)VALUES('$ip', '$fata')";
$result=mysql_query($sql2);
include("verificare_ip.php");
// if successfully updated.
if($result){
echo "";
echo "<br>";
}
else {
echo "Votul nu a putut fi inregistrat! Te rog, incearca mai tarziu";
}
?>
Cod: Selectaţi tot
<?php
$parola="";
$conexiune = mysql_connect(localhost,root,$parola) or die("a.Nu ma pot conecta la MySQL!");
mysql_select_db(voturi_fete, $conexiune) or die("Nu gasesc baza de date");
// Verificam daca ip exista in DB !
$verificare_ip = "SELECT ip FROM voturi WHERE ip = '$ip'";
$result_ip = mysql_query($verificare_ip);
if(mysql_num_rows($result_ip) == 0) { // Verificare IP
$sql="INSERT INTO voturi (ip, poza) VALUES('$ip', '$fata')";
if(mysql_query($sql)) $mesaj = "IP-ul a fost adaugat in baza de date";
}
else { $mesaj = ""; }
?>
<?php echo $mesaj; ?>