奇怪的问题,请大家帮忙看看在线等!
intro.php:
<?
include_once("inc.php");
$user = new User;
$vote = new Vote;
$user->getUser($user_id);
$vister_ip=$REMOTE_ADDR;
$vote_time= date(" Y-m-d, h:i:s");
if($submit)
{
if($vote->addVote($user_id,$vister_ip,$vote_time))
{
$vote->updateNoseCount($user_id);
echo "<script>alert('欢迎您参与投票!');window.history.back();</script>";
}
else
echo "<script>alert('抱歉您的投票失败!');window.history.back();</script>";
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<form action="intro.php?user_id=<?=$user_id;?>" method=post>
<body bgcolor="#FFFFFF" text="#000000">
<table width="773" border="1" cellspacing="1" cellpadding="3" align="center">
<tr>
<td width="255" valign="top"><img src="02.jpg" width="238" height="284"><br>
目前人气:<?echo $user->mNoseCount;?><br>
所在世界:<?echo $user->mGameType;?><br>
游戏角色:<?echo $user->mGameRoll;?> <br>
<br>
<br>
</td>
<td width="506" valign="top"> <b>玩家详细资料 </b>
<hr>
<p> 昵称:<?echo $user->mNickname;?><br>
性别:<?echo $user->Gmender ;?><br>
年龄:<?echo $age;?> <br>
血型:<?echo $user->mBloodType ;?><br>
体重: <?echo $user->mAvoirdupois;?><br>
体型:<?echo $array_body[$user->mBodilyForm];?> <br>
星座:<?echo $array_astro[$user->mConstellation];?><br>
爱好:<?echo $user->mLove;?> <br>
oicq:<?echo $user->mOicq;?> icq:<?echo $usr->mIcq;?> msn:<?echo $user->mMsn;?> <br>
所在地:<?echo $user->mNation;echo $user->mProvince;echo $user->mCity;?> </p>
<p>【自我介绍】<br>
<?echo $user->mUserIntro;?> <br>
【给玩家的话】<br>
<?echo $user->mToEvery;?> <br>
</p>
<input type="submit" name="submit" value="确定投票" width="114" height="30"></td>
</tr>
</table>
</form>
</body>
</html>
class.vote.php:
<?
//class.vote.php
class Vote
{
var $mUserId;
var $mVisterIp;
var $mVoteTime;
var $mDB;
function Vote()
{
$this->mDB = new mysql;
}
function addVote($pUserId,$pVisteIp,$pVoteTime)
{
if(!checkVote($pUserId,$pVisteIp,$pVoteTime))
return false;
$sql="insert into vote set user_id='$pUserId',vister_ip='$pVisteIp',vote_time='$pVoteTime'";
$this->mDB->query($sql);
$this->mDB->getInsertId ();
}
function updateNoseCount($pUserId)
{
$sql="update member set nose_count=nose_count+1 where user_id='$pUserId'";
$this->mDB->query($sql);
return $this->mDB->getInsertId ();
}
function checkVote($pUserId,$pVisterIP,$pVoteTime)
{
$sql="select * from vote where vister_ip='$pVisterIP' and user_id='$pUserId' and vote_time> date_sub(now(),interval 1 day)";
$result=$this->mDB->query($sql);
if( $this->mDB->getNumRows($result)>0)
return false;
else
return true;
}
}
?>
为什么每次执行后总是输出:抱歉您的投票失败!
$vote->addVote($user_id,$vister_ip,$vote_time)已经被执行