我的网站有问题。我想在 php 中创建一个页面。在此页面中,我希望用户邀请用户。但我有一个错误。我不知道该怎么办。谢谢大家。
错误: SQL 错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的 '' 附近使用的正确语法。
并且在标题中有一个连接数据库。这不是我的问题。
我的代码:
<?php
include('header.php');
$n1 = rand(1, 9);
$n2 = rand(1, 9);
if(isset($_POST['send'])) {
$nr1 = base64_decode($_POST['nr1']);
$nr2 = base64_decode($_POST['nr2']);
$emailinvite = $db->EscapeString($_POST['email']);
$rec = $db->FetchArray($db->Query("SELECT id,login FROM `users` WHERE `login`='".$data['login']."'"));
if($nr1 + $nr2 != $_POST['captcha']){
$mesaj = '<div class="error">pliz try again.</div>';
}elseif($_POST['email'] == ""){
$mesaj = '<div class="error">empty email</div>';
}elseif ($db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `email`='".$emailinvite."'")) > 0) {
$mesaj = '<div class="error">your friend register!</div>';
}else{
$newhash = rand(1000000,9999999);
$db->Query("INSERT INTO `inviteuser` (user,emailinvite,hash) values('".$data['login']."','".$emailinvite."','".$newhash."'");
$error = 0;
$subject ="invite to site";
$message="hello
the user {$rec['login']} want to invite you to :
http://www.like2hits.net
click here:
{$site['site_url']}/register.php?hash={$newhash}
thx!";
$header="{$site['site_email']} <{$site['site_email']}>";
$send_contact=mail($emailinvite,$subject,$message,$header);
$mesaj = "<div class=\"success\">thx you!</div>";
}
}?>
<div id="login">
<div class="top">
<h1>invite friend</h1>
</div>
<div class="content"><div class="msg"><?echo $mesaj;?></div>
<form id="form" method="post">
<input type="hidden" name="nr1" value="<? echo base64_encode($n1); ?>" />
<input type="hidden" name="nr2" value="<? echo base64_encode($n2); ?>" />
<fieldset>
<label>email of your friend</label>
<p><span class="fontawesome-user"></span>
<input name="email" type="email" value="" required="required" />
</p>
<label><?=($n1." + ".$n2." = ?")?></label>
<p><span class="fontawesome-user"></span>
<input name="captcha" type="text" value="" required="required" />
</p>
<p style="text-align: center; padding-top: 15px;">
<input type="submit" name="send" value="invite user" />
</p>
</fieldset>
</form>
</div>
</div>
<?
include('footer.php');?>