我想要一个查询来检查用户IP是否已经在数据库中,如果是,则不允许该用户创建新帐户。
这是Register.php,如果你愿意,我会发布所有
<!-- Body Start -->
<div id="body">
<?php
if(!$login)
{
$form = true;
if(isset($_POST['userbox']))
{
$user_ip = $_SERVER['REMOTE_ADDR'];
$user = $_POST['userbox'];
$mail = $_POST['email'];
$pw = $_POST['password'];
$pw2 = $_POST['password2'];
//require_once('includes/recaptchalib.php');
//$resp = recaptcha_check_answer (CMS_PRKEY,
// $_SERVER["REMOTE_ADDR"],
// $_POST["recaptcha_challenge_field"],
//$_POST["recaptcha_response_field"]);
$user = mysql_real_escape_string($user);
$mail = mysql_real_escape_string($mail);
if(check_mail($mail) && $pw == $pw2 && check_name($user) && strlen($user) < 21 && strlen($user) > 5)
{
$sql0 = "SELECT szUserID FROM TGLOBAL_GSP.dbo.TACCOUNT WHERE szUserID = '".$user."'";
$q0 = odbc_exec($ms_con, $sql0);
$nFree = odbc_num_rows($q0);
if($nFree == 0)
{
$sql0 = "SELECT MAX(dwUserID) AS Result FROM TGLOBAL_GSP.dbo.TACCOUNT";
$q0 = odbc_exec($ms_con, $sql0);
$count0 = odbc_fetch_array($q0);
$count = $count0['Result'];
$date = date("Y-m-d H:i:s");
$sql = "INSERT INTO TGLOBAL_GSP.dbo.TACCOUNT(szUserID, szPasswd, bCheck, dFirstLogin, szMail, szLastLoginIp)
VALUES('".$user."','".$pw."', '1', {ts'".$date."'},'".$mail."','".$user_ip."')";
$stmt = odbc_prepare($ms_con, $sql);
odbc_execute($stmt, array($count + 1, $user, $pw, $mail));
echo '<p>Dein Account wurde erfolgreich erstellt! Du kannst dich nun einloggen.<br /><a href="./login.php">» Zum Login</a></p>';
$form = false;
}
else
{
$error = 'Der Benutzername ist bereits vergeben!';
}
}
else
{
$error = 'Das Passwort, die eMail-Adresse oder der Benutzername waren nicht korrekt!';
}
}
if($form)
{
echo '<h4>Register</h4>';
echo'
<form action="register.php" method="post">
<label>Name <small><em>(required)</em></small></label>
<input type="text" name="userbox" id="userbox" />
<label>eMail-Adresse <small><em>(required)</em></small></label>
<input type="text" name="email" id="email" />
<label>Passwort <small><em>(required)</em></small></label>
<input type="password" name="password" id="password" />
<label>Password wiederholen <small><em>(required)</em></small></label>
<input type="password" name="password2" id="password2" /><br /><br />';
//require_once('includes/recaptchalib.php');
//echo recaptcha_get_html(CMS_PUKEY);
echo '<br /><input type="submit" value="Account anlegen" class="read_more2" />
</form>';
if(isset($error))
{
echo '<br /><p>'.$error.'</p>';
}
}
}
else
{
echo '<p>Du kannst keinen Account erstellen, da du eingeloggt bist!<br /><a href="./index.php">» Zurück zur Startseite</a></p>';
}
?>
</div>
<!-- Body end -->