这是我的重置密码页面的代码。当我尝试没有任何造型时,一切正常,但当我在我的原始网页中集成时,没有显示任何内容。
<?php
require("../dbconnect.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>ipv6 | Reset Password</title>
</head>
<body>
<!-- Top content -->
<div class="top-content">
<div class="inner-bg">
<div class="container" >
<div class="row">
<?php
if (isset($_GET['code'])){
$get_email=$_GET['email'];
$get_code=$_GET['code'];
$query=mysql_query("SELECT * FROM member WHERE email='$get_email'");
while ($row=mysql_fetch_assoc($query))
{
$db_code = $row['pass_reset'];
$db_email=$row['email'];
}
if ($get_email == $db_email && $get_code == $db_code)
{
echo "
<form action ='pass_reset_complete.php?code=$get_code' method='POST'>
PASSOWRD= <input type='password' name='newpwd'/><br>
Confirm PASSOWRD= <input type='password' name='newpwd1'/><p>
<input type= 'hidden' name='email' value='$db_email'/>
</form>
";
}
else
echo "
<div class='col-sm-6 col-sm-offset-3 form-box'>
<div class='form-top'>
<div class='form-top-left'>
<h3>Reset Password</h3>
<hr>
<p>Enter your email address and we’ll send you an email with instructions to reset your password.</p>
<form name='forgot.php' method='post' class='login-form'>
<div class='form-group'>
<input type='text' name='email' placeholder='Email Address...' class='form-username form-control' id='form-username' onblur='check();'>
</div>
<input type='submit' value='SUBMIT' name='submit' class='btn btn-success'>
</form>
</div>
</div>
<div class='form-bottom' style='background-color:#fafafa'>
<p >If you don't receive an email from us within a few minutes, check your spam filter as sometimes they end up in there. The email will be from help@teamtreehouse.com.</p>
</div>
</div> ";
if (isset($_POST['submit']))
{
$email=$_POST['email'];
$query=mysql_query("SELECT * FROM member WHERE email='$email'");
$numrow=mysql_num_rows($query);
if($numrow!=0){
$row=mysql_fetch_assoc($query);
$db_email=$row['email'];
if($email== $db_email){
$code=rand(10000,1000000);
//email msg
$to=$db_email;
$subject="Password Reset";
$body="
This is an automated email.Please do not reply to this.
Click the link below or paste it into your browser
http://localhost/forgot/forgot_pass.php?code=$code&email=$email
";
mysql_query("UPDATE member SET pass_reset='$code' WHERE email='$email'");
mail($to,$subject,$body,"FROM:ipv6@learning.org");
echo "CHECK YOUR MAIL";
}
else{
echo "email incorrect";
}
}
else{
echo "THAT DOES NoT EXIST";
}
}
}
?>
</div>
</div>
</div>
</div>
</body>
</html>
我是否在双引号或任何其他错误尝试方面犯了一些错误,请建议
答案 0 :(得分:1)
你错过了其他情况下的{}括号。
if ($get_email == $db_email && $get_code == $db_code)
{
// your stuff
}
else{ // **you missed these brackets**
// your stuff
}
旁注:我建议您使用mysqli_*
或PDO
,因为mysql_*
已弃用且在PHP 7中不可用。