嗨我有一个注册表单,如果我点击忘记密码我收到邮件如果我点击该链接它重定向到更改密码页面在这里我无法更新特定用户的密码。这是我的代码。发送忘记密码邮件时,可以发送隐藏值的确认码
发送邮件:从此代码我将收到电子邮件。
$email=$_POST['email'];
if($_POST['submit']=='Send')
{
$query="select * from registered where email='$email'";
$result=mysql_query($query) or die(error);
if(mysql_num_rows($result))
{
$to = $_POST['email'];
$from .= 'mail@gmail.com' . "\r\n\r\n";
$subject="Password Change link here";
$message.="Click on this link to change your password \r\n";
$message.="http://website.com/accounting/changepassword.php?email=$email";
$success = mail($to, $subject, $message);
echo "Forgot Password link has been sent to your email.Check your email to change your password";
}
else
{
echo "No user exist with this email id";
}
}
link: Click on this link to change your password
http://website.com/accounting/changepassword.php?email=mail@gmail.com
如果我点击该链接,它将重定向到forgetten.php
页面,我的代码为
但我无法更新密码任何人都可以帮助我。如果我点击该链接,它将从此处重定向到此页面,它将改变password.php
Changepassword.php
<form method="POST" action="forgotten.php" id="myform">
<input type='hidden' value="<?php echo $_GET['email'];?>" name='email'>
<div class="form-group">
<label for="psw"><span class="glyphicon"></span> Password</label>
<input id="password" class="form-control" type="password" name="password" placeholder="Enter password here" required/>
</div>
<div class="form-group">
<label for="rpsw"><span class="glyphicon"></span>Confirm Password</label>
<input id="repassword" class="form-control" type="password" name="repassword" placeholder="Retype password here" required/>
</div>
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Create New Password</button>
forgetten.php代码:
<?php
$connection = mysql_connect("localhost", "root", "account") or die(mysql_error());
$db = mysql_select_db("accounting", $connection);
$email=$_POST['email'];
$password=$_POST['password'];
$repassword=$_POST['repassword'];
$sql1="SELECT * FROM registered WHERE email ='$email'";
$result1=mysql_query($sql1);
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
if($query)
{
$to = $_POST['email'];
$from .= 'mail@gmail.com' . "\r\n\r\n";
$subject="Password Changed";
$message.="your password has been changed successfully. \r\n";
$success = mail($to, $subject, $message);
echo "Password has been changed successfully";
}
else{
echo "Insertion Falied";
}
?>
答案 0 :(得分:3)
<强> changepassword.php 强>
Action action = tree.getActionMap().get("cut");
if (action != null) {
SwingUtilities.notifyAction(action);
}
替换为AND
和,
之间的password
repassword
。'
中的email
。 'email'=$result1
更改为email='$email'
更改
$query = mysql_query("update registered SET password = '$password' AND repassword ='$repassword' WHERE 'email'=$result1");
到
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
符合用户要求。
因为,您要将电子邮件发送到changepassword.php
。
您必须为hidden field
创建一个email
,这将提交到 forgottenpassword.php 页面。
检查数据库连接。并且,交叉检查是否所有列名都写得正确。
按原样使用此代码。
<强> ChangePassword.php 强>
<form method="POST" action="forgotten.php" id="myform">
<input type='hidden' value="<?php echo $_GET['email'];?>" name='email'>
<div class="form-group">
<label for="psw"><span class="glyphicon"></span> Password</label>
<input id="password" class="form-control" type="password" name="password" placeholder="Enter password here" required/>
</div>
<div class="form-group">
<label for="rpsw"><span class="glyphicon"></span>Confirm Password</label>
<input id="repassword" class="form-control" type="password" name="repassword" placeholder="Retype password here" required/>
</div>
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Create New Password</button>
</form>
<强> forgotten.php 强>
<?
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("db_name", $connection);
$email=$_POST['email'];
$password=$_POST['password'];
$repassword=$_POST['repassword'];
$sql1="SELECT * FROM registered WHERE email ='$email'";
$result1=mysql_query($sql1);
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
if($query)
{
$to = $email;
$from = 'mail@gmail.com';
$subject="Password Changed";
$message.="your password has been changed successfully. ";
$success = mail($to, $subject, $message);
echo "Password has been changed successfully";
}
?>
答案 1 :(得分:-1)
它正在运作
<?php
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("db_name", $connection);
$email=$_POST['email'];
$password=$_POST['password'];
$repassword=$_POST['repassword'];
$sql1="SELECT * FROM registered WHERE email ='$email'";
$result1=mysql_query($sql1);
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
if($query)
{
$to = $email;
$from = 'mail@gmail.com';
$subject="Password Changed";
$message.="your password has been changed successfully. ";
$success = mail($to, $subject, $message);
echo "Password has been changed successfully";
}
&GT;