- Home
- Categorie
- Coding e Sistemistica
- Coding
- Mettere cookie che riconosce ip al tasto invio
-
Mettere cookie che riconosce ip al tasto invio
ciao prova :
file ip.php
<?php
include("config.php");$ip=$_SERVER['REMOTE_ADDR'];
if($_POST['id'])
{
$id=$_POST['id'];
$id = mysql_escape_String($id);$ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip'");
$count=mysql_num_rows($ip_sql);if($count==0)
{
$sql = "update Messages set down=down+1 where mes_id='$id'";
mysql_query( $sql);$sql_in = "insert into Voting_IP (mes_id_fk,ip_add) values ('$id','$ip')";
mysql_query( $sql_in);}
else
{}
$result=mysql_query("select down from Messages where mes_id='$id'");
$row=mysql_fetch_array($result);
$down_value=$row['down'];
echo $down_value;}
?>config.php
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "my_db";
$mysql_database = "Db";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");?>
