[英]How to change password using php and my sql?
Hi i have a php page where i wrote some html and php code for change password and it is working fine when i run this page on localhost directly. 嗨,我有一个php页面,我在其中编写了一些用于更改密码的html和php代码,当我直接在localhost上运行此页面时,它工作正常。
but when i include this page in any another html page and use it does not work 但是当我将此页面包含在任何其他html页面中并使用它时不起作用
here is my code 这是我的代码
changepassword.php changepassword.php
<?php
session_start();
?>
<?php
$eid=$_SESSION['eid'];
echo $eid;
$conn = mysql_connect("localhost","root","root");
mysql_select_db("helixcrm",$conn);
if(count($_POST)>0) {
$result = mysql_query("SELECT *from login WHERE eid='" . $eid . "'");
$row=mysql_fetch_array($result);
if($_POST["currentPassword"] == $row["password"]) {
mysql_query("UPDATE login set password='" . $_POST["newPassword"] . "' WHERE eid='" . $eid . "'");
$message = "Password Changed";
} else $message = "Current Password is not correct";
}
?>
<html>
<head>
<title>Change Password</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script>
function validatePassword() {
var currentPassword,newPassword,confirmPassword,output = true;
currentPassword = document.frmChange.currentPassword;
newPassword = document.frmChange.newPassword;
confirmPassword = document.frmChange.confirmPassword;
alert(i+j+k);
if(!currentPassword.value) {
currentPassword.focus();
document.getElementById("currentPassword").innerHTML = "required";
output = false;
}
else if(!newPassword.value) {
newPassword.focus();
document.getElementById("newPassword").innerHTML = "required";
output = false;
}
else if(!confirmPassword.value) {
confirmPassword.focus();
document.getElementById("confirmPassword").innerHTML = "required";
output = false;
}
if(newPassword.value != confirmPassword.value) {
newPassword.value="";
confirmPassword.value="";
newPassword.focus();
document.getElementById("confirmPassword").innerHTML = "not same";
output = false;
}
return output;
}
</script>
</head>
<body>
<form name="frmChange" method="post" action="" onSubmit="return validatePassword()">
<div style="width:500px;">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<table border="0" cellpadding="10" cellspacing="0" width="500" align="center" class="tblSaveForm">
<tr class="tableheader">
<td colspan="2">Change Password</td>
</tr>
<tr>
<td width="40%"><label>Current Password</label></td>
<td width="60%"><input type="password" name="currentPassword" id="currentpassword"class="txtField"/><span id="currentPassword" class="required"></span></td>
</tr>
<tr>
<td><label>New Password</label></td>
<td><input type="password" name="newPassword" id="newpassword" class="txtField"/><span id="newPassword" class="required"></span></td>
</tr>
<td><label>Confirm Password</label></td>
<td><input type="password" name="confirmPassword" id ="confirmpassword"class="txtField"/><span id="confirmPassword" class="required"></span></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>
</tr>
</table>
</div>
</form>
</body></html>
this page working fine when i write code like this it does not work 当我编写这样的代码时,此页面工作正常
<script type="text/javascript">
$(document).ready(function() {
$("#resetpassword").click(function() {
$(function() {
$("#RightPaneContainerDiv").load("changepassword.php");
});
});
});
</script>
Reset Password 重设密码
Here above code is not working 这里上面的代码不起作用
How can i achieve my output 我如何实现我的输出
Thanks in advance 提前致谢
You cant load a complete html page into a div in another page. 您无法将完整的html页面加载到另一个页面的div中。 Perhaps the easiest thing to do would be to use an iframe:
也许最简单的方法是使用iframe:
$("#resetpassword").click(function() {
$(function() {
$("#RightPaneContainerDiv").html('<iframe class="cpassword" src="changepassword.php"></iframe>');
});
});
Styled appropriatly with css 使用CSS适当地设置样式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.