我的注册页面上有错误。我现在试图解决这个问题2个小时,但它仍然没有解决。
我的PHP代码:
<?php
define('SSL', true);
$page['dir'] = '\quickregister';
require_once('../includes/core.php');
require_once('./includes/recaptchalib.php');
if(isset($_SESSION['user'])){
header("Location: ".PATH."/me");
exit;
}
ini_set("display_errors", 1);
$data = new register_sql;
$captchaResponse = $input->FilterText($_POST['captchaResponse']);
$privatekey = "THIS IS AN ULTRA SECRET KEY I SHOULD NOT SHARE, I SHOULD TREAT IS AS A PASSWORD";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$captchaResponse);
if(!$resp->is_valid)
{
$error = "De code die je in hebt getypt is ongeldig. Probeer het nog eens.";
}
$espacios = count_chars(@$_POST['bean_name'], 1);
$name = $input->FilterText($_POST['bean_name']);
$filter = preg_replace("/[^a-z\d\-=\?!@:\_]/i", "", $name);
if($user->validName($_SESSION['quickregister']['bean_name']))
{
$Errorz .= 'De naam die je gebruikt is verboden.';
$State = 1;
}
else
if(!empty($espacios[32]))
{
$Errorz .= 'De naam mag geen spaties bevatten.';
$State = 1;
}
if($filter != $name){
$Error .= 'Deze Spacenaam is niet toegestaan<br />';
$State = 1;
}
if(strlen($_POST['bean_name']) < 3 || strlen($_POST['bean_name']) >= 40)
{
$Error .= 'Je Space naam is te lang of te kort.<br />';
$State = 1; }
else
if($user->NameTaken($_SESSION['quickregister']['bean_name']))
{
$Errorz .= "Deze naam is al ingebruik.";
$State = 1;
}
else
if($user->EmailTaken($_SESSION['quickregister']['bean_email']))
{
header("Location: ".PATH."/quickregister/duplicateEmailLogin");
exit;
}
else
if(!$user->validar_email($_SESSION['quickregister']['bean_email']))
{
$Errorz .= 'De e-mail die je hebt ingevoerd is ongeldig.';
$State2 = 1;
}
else
if($_SESSION['quickregister']['bean_email'] !== $_SESSION['quickregister']['bean_retypedEmail'])
{
$Errorz .= 'De e-mails komen niet overeen. Zorg ervoor dat ze hetzelfde zijn.';
$State2 = 1;
$State3 = 1;
}
else
if(strlen($_SESSION['quickregister']['bean_password']) < 6 || strlen($_SESSION['quickregister']['bean_password']) >= 40)
{
$Errorz .= 'Het wachtwoord moet minstens 6 karakters zijn.';
$State4 = 1;
}
if(isset($Errorz))
{
$_SESSION['quickregister']['error'] = $Errorz;
unset($_SESSION['quickregister']['email_pass']);
$_SESSION['quickregister']['age_gate'] = true;
header("Location: ".PATH."/quickregister/email_password");
}
if($error == null)
{
$_SESSION['PHP_CONECT'] = "habbo";
$username = $db->escape_string($_SESSION['quickregister']['bean_name']);
$password = $input->HoloHash($_SESSION['quickregister']['bean_password'], $username);
$look = $input->FilterText($_POST['bean_figure']);
$email = $db->escape_string($_SESSION['quickregister']['bean_email']);
$gender = $_SESSION['quickregister']['gender'];
$birth = $_SESSION['quickregister']['bean_birth'];
$birth = explode('-', $birth2);
$birth2 = $birth2[2].'-'.$birth2[1].'-'.$birth[0];
$scredits = "450000";
$pixels = "6000";
$motto = "Welkom!";
$data->insert1($username,$password,$birth,$look,$motto,$gender,$scredits,$email,$pixels);
$row = $serverdb->fetch_row($data->select3($username));
$serverdb->query("INSERT INTO ".PREFIX."users (id,name,lastvisit,online,ipaddress_last,newsletter,email_verified,show_home,email_friendrequest,email_minimail,email,show_online) VALUES ('".$row[0]."','".$row[1]."','".time()."','".time()."','".$_SERVER[REMOTE_ADDR]."','1','1','1','1','1','".$email."','1')") or die (mysql_error());
$hash = "";
$length = 8;
$possible = "0123456789qwertyuiopasdfghjkzxcvbnm";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($hash, $char)) {
$hash .= $char;
$i++;
}}
$hash = sha1($hash);
$num = $key;
$db->query("INSERT INTO ".PREFIX."verify (id,email,key_hash) VALUES ('".$row[0]."','".$email."','".$hash."')");
$subject = "Welkom in ".SHORTNAME;
$to = $email;
$html =
'<html><head><style type="text/css">
a { color: #fc6204; }
</style></head>
<body style="background-color: #e3e3db; margin: 0; padding: 0; font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000;">
<div style="background-color: #bce0ee; padding: 14px; border-bottom: 3px solid #000;">
<img src="cid:habbologo" alt="http://yabsoon.nl" />
</div>
<div style="padding: 14px 14px 50px 14px; background-color: #e3e3db;">
<div style="background-color: #fff; padding: 14px; border: 1px solid #ccc">
<h1 style="font-size: 16px"><font color="black"><b>Beste '.$row[1].',</b></font></h1>
<p>
Het is belangerijk dat je bevestigt dat dit e-mail addres van jou is, <br />
Klik op de volgende link om jou Space account te activeren: <a href="'.PATH.'/email?key='.$hash.'">'.$lang->loc['email.verify.2.b'].'</a>
</p>
<p>
Bewaar de volgende gegevens veilig:
</p>
<p>
<b>'.$lang->loc['email.verify.4'].'</b> '.$row[1].'<br>
<b>'.$lang->loc['email.verify.5'].'</b> '.$birth.'
</p>
<p>
Heb je je niet geregistreerd op Yabsoon? Klik dan <a href="'.PATH.'/email?remove='.$hash.'">hier!</a>
</p>
</div>
<div style="padding: 14px 0; text-align: center; font-size: 10px;">
Copyright © 2006-2012 Space hotel. Alle rechten voorbehouden.
</div>
</div>
</body>
</html>';
$db->query("INSERT INTO ".PREFIX."homes (ownerid,itemid,x,y,z,skin,location) VALUES ('".$row[0]."','220','252','12','66','defaultskin','0')");
$db->query("INSERT INTO ".PREFIX."homes (ownerid,itemid,x,y,z,skin,location) VALUES ('".$row[0]."','10400','38','263','88','defaultskin','0')");
$db->query("INSERT INTO ".PREFIX."homes (ownerid,itemid,x,y,z,skin,location) VALUES ('".$row[0]."','10600','59','646','103','defaultskin','0')");
$db->query("INSERT INTO ".PREFIX."homes (ownerid,itemid,x,y,z,skin,location) VALUES ('".$row[0]."','10100','437','29','79','defaultskin','0')");
$db->query("INSERT INTO ".PREFIX."homes (ownerid,itemid,x,y,z,skin,location) VALUES ('".$row[0]."','10700','438','262','83','defaultskin','0')");
unset($_SESSION['quickregister']);
$user = new HoloUser($username,$password,true);
$_SESSION['user'] = $user;
header("Location: ".PATH."/security_check");
exit;
}
else{
$_SESSION['quickregister']['error'] = $error;
header('Location: '.PATHSECURE.'/quickregister/captcha');
exit;
}
?>
我收到此错误:错误的整数值:&#39;&#39;对于列&#39; id&#39;在第1行有人知道我做错了吗?
答案 0 :(得分:0)
您正在使用需要数字的字符串。删除行[0]
周围的单引号你有
$db->query("INSERT INTO ".PREFIX."verify (id,email,key_hash) VALUES ('".$row[0]."','".$email."','".$hash."')");
应该是
$db->query("INSERT INTO ".PREFIX."verify (id,email,key_hash) VALUES (".$row[0].",'".$email."','".$hash."')");
你有多个地方。您还应该使用易受SQL注入攻击的预处理语句。
答案 1 :(得分:0)
我无法评论,所以我会在这里发布。我认为问题在于以下几个方面:
$data->insert1($username,$password,$birth,$look,$motto,$gender,$scredits,$email,$pixels);
$row = $serverdb->fetch_row($data->select3($username));
检查$ row中的内容并告诉我们。
var_dump($row);
更新
经过多次评论后,我们发现问题在于表格中的id列&#34;用户&#34;不得不改为auto_increment。另外,在&#34; insert1&#34;函数在插入查询列上缺少一些单引号。