0
你好,我的問題是,如果我改變我的ip,但我有相同的cookie它會去其他語句,並執行查詢時,它應該失敗。我不知道爲什麼它不計算$ cookie參數。mysql select有3個條件問題
<?php
require_once('../core/dbconfig.php');
$dbc = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASS, DB_NAME);
$ip_adress=$_SERVER['REMOTE_ADDR'];
$cookie=$_COOKIE['Cookie'];
$id_user=$_POST['id_user'];
$query="Select * from IP_Cookie_Verify where ID_User='$id_user' and Cookie='$cookie' and IP='$ip_adress'";
$result=mysqli_query($dbc,$query) or die("query failed: " . mysqli_error($dbc));
if($row = mysqli_fetch_array($result))
{
echo'fail';
}
else
{
$query="Insert into IP_Cookie_Verify (IP,ID_User,Cookie) VALUES ('$ip_adress','$id_user','$cookie')";
$result=mysqli_query($dbc,$query) or die("query failed: " . mysqli_error($dbc));
$queryz="Update `users` SET Voturi=Voturi+1 where id='$id_user'";
$resultz=mysqli_query($dbc,$queryz) or die("query failed: " . mysqli_error($dbc));
$query="Select * from `users` where id='$id_user'";
$result=mysqli_query($dbc,$query) or die("query failed: " . mysqli_error($dbc));
while ($row = mysqli_fetch_array($result))
{
$voturi=$row['Voturi'];
}
echo''.$voturi.'';
}
你試圖使用'$ _SESSION'呢? – CIRCLE
如果您需要在同一頁面上使用cookie,您爲何要使用cookie?嘗試改變值$ cookie = $ _ COOKIE ['ck_abc']; – Naeem
不應該是問題原因,如果我回聲$ cookie它返回我我的cookie – user3058067