这就是我想找出用户是否存在于数据库中的方式,但是当它不这样做时,它会不断地保持自己的存在。
我想从这段代码中获得关于数据库中用户的知识,如果它没有做到必须清楚地说出来:)
}
else
{
$email_1 = $_post["email"];
$result = $this->mysqli->query("SELECT * FROM bruger WHERE email='$email_1'");
if(mysqli_num_rows($resut) > 0)
{
//code here!
}
else
{
?>
<div class="article-main-content">
<div class="alert-message" style="background-color:#c22525;"><span class="icon-text">⚠</span><span class="alert-content">Email Findes på hjemmesiden</span><a href="#" class="destroy-button"></a></div>
</div>
<?php
}
}
}
我在这里尝试过:
$email = $_post["email"]
foreach($this->mysqli->query("SELECT * FROM `bruger` WHERE email='$email'") as $row) {
if ($row['email'] !== $email) {
这是我所有的html代码:
<form action="#" enctype="multipart/form-data" method="post">
<table width="100%" cellpadding="5" cellspacing="5">
<tr>
<td><p>Email</p></td>
<td><input type="text" name="email" class="ned_input"></td>
</tr>
<tr>
<td><p>Adgangskode</p></td>
<td><input type="password" name="password_adgangskode_1" class="ned_input"></td>
</tr>
<tr>
<td><p>Adgangskode Gentag</p></td>
<td><input type="password" name="password_adgangskode_2" class="ned_input"></td>
</tr>
<tr>
<td><p>Fornavn</p></td>
<td><input type="text" name="fornavn" class="ned_input"></td>
</tr>
<tr>
<td><p>Efternavn</p></td>
<td><input type="text" name="efternavn" class="ned_input"></td>
</tr>
<tr>
<td><p>Profilbillede</p></td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="opret" value="Opret bruger" style="margin-top:10px;"></td>
</tr>
</table>
</form>
EIDT 这里
if ($stmt = $this->mysqli->prepare("SELECT `id` FROM `bruger` WHERE `email`"))
{
$stmt->bind_param('s', $email_indhold);
$email_indhold = $_POST["email"];
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id);
$stmt->fetch();
$count = $stmt->num_rows;
$stmt->close();
if($count > 0)
{