我在我的页面中有以下声明,它似乎没有处理,任何人都可以看到任何明显的错误,我错过了吗?
else{
if($usersClass->register($_POST['produgg_username'], md5($_POST['produgg_password']), $_POST['produgg_email'], $randomkey))
{
print "success";
$toemail = $_POST['produgg_email'];
$touser = $_POST['produgg_username'];
// Send activation email
$to = $toemail;
$subject = "Activation";
$headers = "From: support@.co.uk";
$body = "Howdy $touser!";
mail($to, $subject, $body, $headers);
if(isset($_POST['r']) {
$refcode = mysql_real_escape_string($_POST['r']);
mysql_query(" UPDATE produgg_users SET credits=credits+200000 where produgg_users.id = ".$refcode or die(mysql_error());
};
}else{
print "error!";
}
}
答案 0 :(得分:1)
这一行会出错:
mysql_query(" UPDATE produgg_users SET credits=credits+200000 where produgg_users.id = ".$refcode or die(mysql_error());
应该像
mysql_query(
"UPDATE produgg_users SET credits=credits+200000 where produgg_users.id = ".$refcode)
or die(mysql_error());
答案 1 :(得分:1)
你的isset函数缺少右括号
if( isset($_POST['r']) ) {
$refcode = mysql_real_escape_string($_POST['r']);
mysql_query(" UPDATE produgg_users SET credits=credits+200000 where produgg_users.id = ".$refcode or die(mysql_error());
};
答案 2 :(得分:0)
如果不知道$usersClass->register()
返回什么,就很难确定出错的地方。我建议你尝试类似下面的内容(仅用于调试目的):
var_dump($_POST);
$_test = $usersClass->register($_POST['produgg_username'], md5($_POST['produgg_password']), $_POST['produgg_email'], $randomkey);
var_dump($_test);
// proceed on with your if statement.
确保您看到了您期望看到的内容。开发代码中的一些回声从不会伤害任何人,只需确保将其删除以用于发布目的。