heshan Posted August 9, 2012 Share Posted August 9, 2012 Hi guys, I have a problem in "change password" function. The below code does not support "change password" thing. Can anyone help me out? changePasword.php <form id="form1" name="form1" method="post" action="changePasworddb.php"> <?php $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); ?> <table width="850" border="1" align="center" bgcolor="#00FFFF"> </table></td> </tr> <tr> <td width="170"> </td> <td width="664"><table width="660" border="0"> <tr> <td width="124"> </td> <td width="124"> </td> <td width="124"> </td> <td width="124" align="center">Change Password</td> <td width="129" align="center"><a href="../Home page/new student registration/signout.php">Signout</a></td> </tr> </table></td> </tr> <tr> <td> </td> <td><label>Current password</label> </td> <td colspan="2"> <?php $query="SELECT username,password FROM administrator "; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $username=$row['username']; $password=$row['password']; } echo $password; ?></td> <td> </td> <td> </td> </tr> <tr> <td><input type="hidden" name="grade" value="<?php echo $username;?>"/></td> <td><input type="hidden" name="grade" value="<?php echo $password;?>"/></td> <td width="85"> <input type="submit" name="button" id="button" value="Save" onClick="return Validate1();"/> </td> <td width="120"> <input type="button" name="button2" id="button2" value="Reset" onClick="return Validate();"/> </td> </table> </form> changePasworddb.php <?php $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $username=$_POST['username']; $password=$_POST['password']; $newpassword=$_POST['newpassword']; $query="UPDATE administrator SET password='$newpassword' where username='$username'"; $result=mysql_query($query) or die (mysql_error()); header("location:add techer/addAdminterpage.php"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/ Share on other sites More sharing options...
The Little Guy Posted August 9, 2012 Share Posted August 9, 2012 we need more information other than "it doesn't support it". What is happening? What is going wrong? What errors are you getting (if any)? What are you expecting to happen? Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368147 Share on other sites More sharing options...
gristoi Posted August 9, 2012 Share Posted August 9, 2012 have you even tried to debug this, you dont even have an input field to enter the new password into ??? Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368149 Share on other sites More sharing options...
heshan Posted August 9, 2012 Author Share Posted August 9, 2012 Herewith i re-submit my form.. Actually what is happening is after change an existing password and click on "save" button the data is saved.(no error messages) But in the database the old password is still showing. But what i actually want is to replace the old password with the new password. <form id="form1" name="form1" method="post" action="changePasworddb.php"> <?php $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); ?> <table width="850" border="1" align="center" bgcolor="#00FFFF"> <tr> <td colspan="2"><table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="25%"><img src="../IMAGE/banner - Copy.jpg" width="186" height="136" /></td> <td width="75%" align="center" valign="middle"><div align="center"><img src="../IMAGE/banner.jpg" width="733" height="137" /></div></td> </tr> </table></td> </tr> <tr> <td width="170"> </td> <td width="664"><table width="660" border="0"> <tr> <td width="124"><a href="../Home page/new student registration/add_or_manage.php">Manage Data</a></td> <td width="124"> </td> <td width="124"> </td> <td width="124" align="center">Change Password</td> <td width="129" align="center"><a href="../Home page/new student registration/signout.php">Signout</a></td> </tr> </table></td> </tr> <tr> <td height="59" valign="top"><ul id="MenuBar1" class="MenuBarVertical"> <li><a href="../../add admin users/add techer/addAdminUser.php">Add Admin Login</a> </li> <li><a href="../../Student registration/new student registration/newStudentRegistrationForm.php">Add Student</a></li> <li><a href="../../student attendance/add attendance/addStudentAttendance.php">Add Student Attendance</a> </li> <li><a href="../../Student time table/add1 time table/addTimeTable.php">Add Time Table</a></li> <li><a href="../../Student marks/add student marks/addStudentMark.php">Add Student Marks</a></li> <li><a href="../../manage subject/add subject.php">Add Subject</a></li> <li><a href="../../search student information/SearchStudentInformation.php">Search Student Information</a></li> <li><a href="../../student payments reports/studentsPayments.php">Student Payment Reports</a></li> <li><a href="../../Issue certificate/issueCertificate.php">Issue Certificates</a></li> </ul> <p> </p> <p> </p></td> <td valign="top"><table width="659" border="0"> <tr> <td width="16"> </td> <td width="147"> </td> <td colspan="2"> </td> <td width="124"> </td> <td width="125"> </td> </tr> <tr> <td> </td> <td colspan="3"><h3> <label>Change Password</label> </h3></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>Current password</label> </td> <td colspan="2"> <?php $query="SELECT username,password FROM administrator "; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $username=$row['username']; $password=$row['password']; } echo $password; ?></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>New password</label> </td> <td colspan="2"> <input type="password" name="newpassword" id="textfield2" /> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>Confirm password</label> </td> <td colspan="2"> <input type="password" name="confirmpassword" id="textfield3" /> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> </tr> <tr> <td><input type="hidden" name="grade" value="<?php echo $username;?>"/></td> <td><input type="hidden" name="grade" value="<?php echo $password;?>"/></td> <td width="85"> <input type="submit" name="button" id="button" value="Save" onClick="return Validate1();"/> </td> <td width="120"> <input type="button" name="button2" id="button2" value="Reset" onClick="return Validate();"/> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <p> </p></td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368154 Share on other sites More sharing options...
gristoi Posted August 10, 2012 Share Posted August 10, 2012 like i said in my previous comment, you are not posting username over to the changepasswordDb. you have two hidden fields with the name set to grade, not username and password. so you are in effect telling the query to $query="UPDATE administrator SET password='$newpassword' where username=''"; so it will never update. change the input names from grade to username and password accordingly Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368305 Share on other sites More sharing options...
heshan Posted August 10, 2012 Author Share Posted August 10, 2012 @ gristoi : Thanks a lot. now it is working.. Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368455 Share on other sites More sharing options...
maxudaskin Posted August 10, 2012 Share Posted August 10, 2012 Quote Link to comment https://forums.phpfreaks.com/topic/266869-problem-in-change-password-function/#findComment-1368457 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.