我想问一下我们网站文件中包含的这个投票箱。因为这似乎有问题。每当我点击“点击此处投票”。什么都没发生,我不知道为什么因为我没有进入java编码。我想要包含它的代码,以便你们可以看看。
这是投票箱:http://i.stack.imgur.com/3LV8S.png
所以这是你要点击它的代码:
if(isset($_SESSION['user'])) {
odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
$votepoints = odbc_exec($mssql, 'SELECT votepoints FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
echo 'Current Vote Points: <b><span id="currvp">'.odbc_result($votepoints, 'votepoints').'</span></b><br/><br/>';
echo '<span id="takeitem"></span>';
echo '<a href="javascript:voteTab();"><b>Click here to vote!</b></a>';
} else {
echo '<b>You must login before you can vote!</b>';
}
这是voteTab();功能:
function voteTab() {
$.ajax({
url: 'ajax.php?a=vote',
type: 'GET',
dataType: 'php',
timeout: 1000,
success: function(response){
$(".boxcontent").html(response);
}
});
这是ajax:投票功能:
if($_GET['a'] == 'vote') { // Vote Box
odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
$userselect = odbc_exec($mssql, 'SELECT * FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
$user = odbc_fetch_array($userselect);
$diff1 = diff($user['lastvote1']);
$diff2 = diff($user['lastvote2']);
$diff3 = diff($user['lastvote3']);
$votedtoday = 0;
if($diff1['hours'] < 12)
$votedtoday = $votedtoday + 1;
if($diff2['hours'] < 12)
$votedtoday = $votedtoday + 1;
if($diff3['hours'] < 12)
$votedtoday = $votedtoday + 1;
echo 'Username: <b>'.$user['account'].'</b><br/><br/>';
echo 'Current Vote Points: <b><span id="vpoints">'.$user['votepoints'].'</span></b><br/><br/>';
echo 'You can vote <b><span id="vtoday"> '.(3 - $votedtoday).' </span></b> more times today.<br/><br/>';
if($diff1['hours'] >= 12 || $diff2['hours'] >= 12 || $diff3['hours'] >= 12) {
if(isset($_GET['submit'])) {
if($_GET['submit'] == 1) {
if($diff1['hours'] >= 12) {
odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_GET['submit']).'=\''.date('d.m.Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
}
} elseif($_GET['submit'] == 2) {
if($diff2['hours'] >= 12) {
odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_GET['submit']).'=\''.date('d.m.Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
}
} elseif($_GET['submit'] == 3) {
if($diff3['hours'] >= 12) {
odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_GET['submit']).'=\''.date('d.m.Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
}
}
}
echo 'You gain 1 Vote Point each topsite.<br/>After voting you will be able to choose a free gift!<br/>Follow the instructions to vote for all 3 topsites.<br/><br/><div id="topsite" style="text-align: center;">';
if($diff1['hours'] >= 12) {
// Top of Games
echo '<img src="img/tog.gif" /><br/><br/>';
echo '<span id="votetext"><a onclick="vote(1, '.$diff2['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist1.'" target="_blank">Click here to continue!</a></span>';
} elseif($diff2['hours'] >= 12 ) {
// Xtreme Top 100
echo '<img src="img/xtop100.jpg" /><br/><br/>';
echo '<span id="votetext"><a onclick="vote(2, '.$diff3['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist2.'" target="_blank">Click here to continue!</a></span>';
} elseif($diff3['hours'] >= 12) {
// G Top 100
echo '<img src="img/gtop100.jpg" /><br/><br/>';
echo '<span id="votetext"><a onclick="vote(3, 0, \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist3.'" target="_blank">Click here to continue!</a></span>';
}
echo '</div>';
} else {
echo '<a href="javascript:voteItemTab();">Choose an item!</a>';
}
}
/* VOTE BOX END */
我真的需要一些关于它如何运作的答案。
答案 0 :(得分:0)
您的PHP代码可能存在处理数据库连接的问题。如果你尝试将错误捕获/中断(在处理数据库的每一行上)更好 并检查 error.log 以查看可能在后台中断的内容。
当你做AJAX请求时,我也注意到了一些安全漏洞,MITM攻击可以改变你的PHP代码的响应,同时也尝试清理请求和响应。
答案 1 :(得分:0)
你的功能上缺少一个闭合卷曲支撑。
function voteTab() {
$.ajax({
url: 'ajax.php?a=vote',
type: 'GET',
dataType: 'php',
timeout: 1000,
success: function(response){
$(".boxcontent").html(response);
}
});
}