pixeltrace Posted February 19, 2007 Share Posted February 19, 2007 guys, i need help on my change password form. it seems that its not updating the password to the new password and whenever i click on the update button its opening a new page. i got 2 page 1. useracct.php 2. changepass.php also in my useracct.php i have there a code for the <? $userIP = getenv("REMOTE_ADDR"); echo "$userIP"; ?> i dont know what wrong with my code but its not getting the computer's current IP this is the code for my useracct.php <? session_start(); if (session_is_registered("username")){ if($_SESSION['user_level'] == 'administrator'){ $username = $_SESSION['username']; //$username = $_POST['username']; include 'db_connect.php'; $query = mysql_query("SELECT userid, username, first_name, last_name, job_title, email, user_level FROM admin_user WHERE username= '$username'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $userid = $row["userid"]; $username = $row["username"]; $first_name = $row["first_name"]; $last_name = $row["last_name"]; $job_title = $row["job_title"]; $email = $row["email"]; $user_level = $row["user_level"]; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>:: JobHiRings :: Administration Page</title> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; } --> </style> <link href="css.css" rel="stylesheet" type="text/css"> </head> <body> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="3"><img src="images/header.gif" width="778" height="148"></td> </tr> <tr> <td width="16" rowspan="2" align="left" valign="top" background="images/left.gif"><img src="images/left.gif" width="16" height="14"></td> <td width="745" valign="top"><table width="746" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3" class="text4">USER ACCOUNT INFORMATION </td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="2" valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> <td width="214" valign="top"><? include 'sidemenu.php'; ?> </td> <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> </table></td> <td width="519" align="center" valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> <td width="214" valign="top"><table width="460" border="0" cellspacing="2" cellpadding="0"> <tr> <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="8"></td> </tr> <tr> <td colspan="3" bgcolor="#999999"> </td> </tr> <tr> <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td width="137" align="right" class="text6">account ID : </td> <td> </td> <td class="text7">USR<? echo "$userid"; ?></td> </tr> <tr> <td align="right" class="text6">username : </td> <td width="7" rowspan="2"> </td> <td width="308"><span class="text7"> <? echo "$username"; ?> </span></td> </tr> <tr> <td align="right" class="text6">name : </td> <td width="308"><span class="text7"> <? echo " ".$first_name." ".$last_name." "; ?> </span></td> </tr> <tr> <td align="right" class="text6">job title : </td> <td> </td> <td><span class="text7"> <? echo "$job_title"; ?> </span></td> </tr> <tr> <td align="right" class="text6">email address : </td> <td> </td> <td><span class="text7"> <? echo "$email"; ?> </span></td> </tr> <tr> <td align="right" class="text6">user level : </td> <td> </td> <td><span class="text7"> <? echo "$user_level"; ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="right" class="text6">last login : </td> <td> </td> <td><span class="text7"> <? echo date('m-j-Y'); ?> </span></td> </tr> <tr> <td align="right" class="text6">IP address used : </td> <td> </td> <td><span class="text7"> <? $userIP = getenv("REMOTE_ADDR"); echo "$userIP"; ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <form target="changepass.php" method="post"> <tr> <td align="right" class="text6">change password : </td> <td> </td> <td> </td> </tr> <tr> <td align="right" class="text6">new : </td> <td> </td> <td><input type="password" name="newpasswd"></td> </tr> <tr> <td align="right" class="text6">confirm new password : </td> <td> </td> <td><input type="password" name="newpasswd2"></td> </tr> <tr> <td rowspan="2"> </td> <td rowspan="2"> </td> <td><input type="submit" name="update" value="update"></td> </tr> <tr> <td> </td> </tr> </form> </table></td> <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> </table></td> </tr> <tr> <td colspan="3"> </td> </tr> </table></td> <td width="16" rowspan="2" align="right" valign="top" background="images/right.gif"><img src="images/spacer.gif" width="1" height="1"><img src="images/right.gif" width="16" height="14"></td> </tr> <tr> <td valign="top"><img src="images/spacer.gif" width="746" height="10"></td> </tr> <tr> <td colspan="3" background="images/footer.gif"><table width="583" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="12" rowspan="2"><img src="images/spacer.gif" width="12" height="43"></td> <td width="560" height="10" valign="top"><img src="images/spacer.gif" width="12" height="10"></td> <td width="12" rowspan="2"><img src="images/spacer.gif" width="12" height="43"></td> </tr> <tr> <td align="center" valign="top" class="footer">Copyright © 2007 www.jobhirings.com. All Rights Reserved</td> </tr> </table></td> </tr> </table> <? }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } }else{ echo '<script language=javascript>top.location = "index.php";</script>'; } ?> </body> </html> and this is the code for my changepass.php <? session_start(); if (session_is_registered("username")){ $username = $_SESSION['username']; $newpasswd = $_POST['newpasswd']; $newpasswd2 = $_POST['newpasswd2']; if ($newpasswd = $newpasswd2) { include 'db_connect.php'; $password = md5($newpasswd); $sql="UPDATE admun_user SET password='$password' WHERE username='$username'"; mysql_query($sql) or die("error:".mysql_error()); if ($_SESSION['user_level'] == 0) { echo '<script language=javascript>alert("Password has been changed");top.location = "useracct.php?username='.$username.'";</script>'; } else echo '<script language=javascript> alert("Password does not match!");top.location = "useracct.php?username='.$username.'";</script>'; }else{ echo '<script language=javascript> alert("You are not authorized to access this page!");top.location = "main.php";</script>'; } }else{ echo '<script language=javascript>top.location = "index.php";</script>'; } ?> hope you could help me with this. thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/ Share on other sites More sharing options...
jwk811 Posted February 19, 2007 Share Posted February 19, 2007 $sql="UPDATE admun_user SET password='$password' WHERE username='$username'"; mysql_query($sql) or die("error:".mysql_error()); i think you might of spelt admin wrong lol, was that it? Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/#findComment-188416 Share on other sites More sharing options...
pixeltrace Posted February 19, 2007 Author Share Posted February 19, 2007 yes. it should be admin_user i changed it already but i still cant update the password. also in my useracct.php howcome whenever i click on the update button its opening a new window of the same page? what could be wrong in my codes? need help. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/#findComment-188419 Share on other sites More sharing options...
pixeltrace Posted February 19, 2007 Author Share Posted February 19, 2007 any update on this? appreciate your help thanks! Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/#findComment-188435 Share on other sites More sharing options...
pixeltrace Posted February 19, 2007 Author Share Posted February 19, 2007 help please! Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/#findComment-188473 Share on other sites More sharing options...
superuser2 Posted February 19, 2007 Share Posted February 19, 2007 As to getting the ip address: $_SERVER['REMOTE_ADDR']; if ($newpasswd = $newpasswd2) should be if($newpasswd == $newpasswd2) Also you have to close your if(session_is_registered) at the end, you say else but you don't have a closing bracket for it. Put error_reporting(E_ALL) at the top of the page and you'll see any other errors. Quote Link to comment https://forums.phpfreaks.com/topic/39121-need-help-on-change-password-form/#findComment-188534 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.