使用PHP忘记密码链接有困难
嗨,我有一个忘记密码脚本,当用户点击电子邮件链接时,它会发送回密码重置页面。单击后,它将转到所需页面,但两个发送表单都出现问题。我还有一个忘记的密码文件。如果你看过这张照片,那就是接下来要发生的事情。我对PHP有点陌生。我只想显示新密码和确认新密码的形式 剧本:使用PHP忘记密码链接有困难,php,Php,嗨,我有一个忘记密码脚本,当用户点击电子邮件链接时,它会发送回密码重置页面。单击后,它将转到所需页面,但两个发送表单都出现问题。我还有一个忘记的密码文件。如果你看过这张照片,那就是接下来要发生的事情。我对PHP有点陌生。我只想显示新密码和确认新密码的形式 剧本: 在第二个表单之前,可以添加一个else条件,如下所示 <div class="container"> <div class="row"> <?php require_once 'conn
在第二个表单之前,可以添加一个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
?>
从您的脚本中,有两个表单显示相同的内容。删除一个。但是,如果我删除上面的表单,密码重置表单将不起作用。删除下面的表单。如果我删除下面的表单,表单将发送URL的实际pasword rest电子邮件以及表单进程的代码
<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
?>