我在一个项目中工作,我需要将数据存储在 cookie 中并在 mysql 查询中使用该数据,但不确定安全性.. 好吧,这是我的代码..
if(isset($_COOKIE['user_phone_id'])){
echo "";
$user_phone = $_COOKIE['user_phone'];
$user_phone_id = $_COOKIE['user_phone_id'];
$user_phone_url = strtr($user_phone, " ", "-");
echo "";
echo "<div id='phonelist_1' class='phonelist'>
<a style='color:white;font:bold 15px arial,helvetica,sans-serif; ' href='$user_phone_url'>
<img src='./phones/".$user_phone_id.".jpg' alt='$user_phone' title='$user_phone' width='100px' height='100px' />
</a><br />
<a style='color:white;font:bold 15px arial,helvetica,sans-serif; ' href='$user_phone_url' title='$user_phone'>
$user_phone
</a><br /><div class='mobilebg'>";
require_once "./phonec.php";
$sql = "select mobile_name, mobile_id, parent_id from mobiles where parent_id =" .
$user_phone_id . " ";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
$cid = $rs['mobile_id'];
$cname = $rs['name_name'];
echo " <a href='./$cid' style='width: 100%; text-decoration:none;'>
<div class='mobilatcat'>
<em style='float: right;'></em>
<em style='padding-right: 20%;float: right;'>$cname</em>
<hr style='margin: 5px;' /></div></a>";
}
echo "</div></div> ";
}