您好我忘记了密码脚本,当用户点击电子邮件链接并将其发送回密码重置页面时。点击后,它会转到所需的页面,但是两个发送表单都出现问题。我也有一个忘记的密码文件。如果您已经看过这张照片,那就是即将发生的事情。我对PHP有点新鲜。我只想显示新密码并确认新密码表单。
https://www.dropbox.com/s/y2qhxovodk3rlrv/2015-07-15_0814.png?dl=0
脚本:
<div class="container">
<div class="row">
<?php
require_once 'connection.php';
if (isset($_GET['code']))
{
$get_username = $_GET['username'];
$get_code = $_GET['code'];
$query = mysqli_query($connection,"SELECT * FROM user_tbl WHERE username='$get_username'");
while ($row1s = mysqli_fetch_assoc($query))
{
$db_code= $row1s['passreset'];
$db_username= $row1s['username'];
}
if ($get_username == $db_username && $get_code == $db_code )
{
echo "
<form action='forgotpassword_process.php' method='post'>
<legend><h1 style='color:red;'>Forgot Password</h1></legend><br>
<div class='input-field col s6'>
<div class='form-group'>
<span class='help-block'>Enter Your New Password</span>
<input type='password' name='newpass' class='form-control' placeholder='New Password '>
</div>
</div>
<div class='input-field col s6'>
<div class='form-group'>
<span class='help-block'>Re-Enter Your Password </span><br>
<input type='password' name='password1' class='form-control' placeholder='Password'>
</div>
</div>
<input type='submit' name='submit' class='btn' value='Update Password' />
<input type='hidden' name='username' class='btn' value='$db_username' />
</form>
";
}
}
?>
<form action="forgotpassword_process.php" method="post">
<legend><h1 style="color:red;">Forgot Password</h1></legend><br>
<div class="input-field col s6">
<div class="form-group">
<span class="help-block">Enter your username</span>
<input type="text" name="username" class="form-control" placeholder="User Name">
</div>
</div>
<div class="input-field col s6">
<div class="form-group">
<span class="help-block">Enter your email </span><br>
<input type="text" name="email" class="form-control" placeholder="Password">
</div>
</div>
<input type="submit" name="submit" class="btn" value="submit" />
</form>
</div>
</div>
答案 0 :(得分:0)
在第二个表单之前,您可以添加else
条件,例如
<div class="container">
<div class="row">
<?php
require_once 'connection.php';
if (isset($_GET['code']))
{
$get_username = $_GET['username'];
$get_code = $_GET['code'];
$query = mysqli_query($connection,"SELECT * FROM user_tbl WHERE username='$get_username'");
while ($row1s = mysqli_fetch_assoc($query))
{
$db_code= $row1s['passreset'];
$db_username= $row1s['username'];
}
if ($get_username == $db_username && $get_code == $db_code )
{
echo "
<form action='forgotpassword_process.php' method='post'>
<legend><h1 style='color:red;'>Forgot Password</h1></legend><br>
<div class='input-field col s6'>
<div class='form-group'>
<span class='help-block'>Enter Your New Password</span>
<input type='password' name='newpass' class='form-control' placeholder='New Password '>
</div>
</div>
<div class='input-field col s6'>
<div class='form-group'>
<span class='help-block'>Re-Enter Your Password </span><br>
<input type='password' name='password1' class='form-control' placeholder='Password'>
</div>
</div>
<input type='submit' name='submit' class='btn' value='Update Password' />
<input type='hidden' name='username' class='btn' value='$db_username' />
</form>
";
}
} else {
?>
<form action="forgotpassword_process.php" method="post">
<legend><h1 style="color:red;">Forgot Password</h1></legend><br>
<div class="input-field col s6">
<div class="form-group">
<span class="help-block">Enter your username</span>
<input type="text" name="username" class="form-control" placeholder="User Name">
</div>
</div>
<div class="input-field col s6">
<div class="form-group">
<span class="help-block">Enter your email </span><br>
<input type="text" name="email" class="form-control" placeholder="Password">
</div>
</div>
<input type="submit" name="submit" class="btn" value="submit" />
</form>
</div>
</div>
<?php
} // end else
?>