romio Posted April 11, 2006 Share Posted April 11, 2006 I use this code to allow the a user to change his/her User_Name and Password, the code works fine, i did have some problem with the refresh button so i added [code]header("Location: $_SERVER[PHP_SELF]");[/code]to clear my cache to avoid the refresh button problem, but i do have a problem that i cant show my error msg incase the user input wrong Current_password, i have tried using $error variable and increase it by one and then check if the $error is <> 0 then output the error msg, but it didnt work, anyone got an idea to solve this?Thanks.[code]<?phprequire_once('include/config.inc.php');session_start();$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_POST['username'])) { $loginUsername= $_POST['username']; $password = md5($_POST['password']); $new_password = md5($_POST['new_password']); $get_records = "SELECT * FROM access where username = '$loginUsername'"; $query_change_password = mysql_query($get_records); $query_change_password_rows = mysql_num_rows($query_change_password); if(!($query_change_password_rows)) { header("Location: $_SERVER[PHP_SELF]"); } else { $update_password = "UPDATE access SET username = '$loginUsername', password = '$new_password' WHERE username = '$loginUsername'"; $update_password_query = mysql_query($update_password); echo "<br /><br /><div align=center><span class='style2'>Your Password Has Been Changed Successfully, You will be Redirected Soon</span></div>"; echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"2; url=admin.php\">"; }}// else// {// echo "<br /><br /><div align=center><span class='style2'>Error, Pleaes Enter The Correct Current Password</span></div>";// }?> [/code] Quote Link to comment Share on other sites More sharing options...
shortj75 Posted April 11, 2006 Share Posted April 11, 2006 instead of this header("Location: $_SERVER[PHP_SELF]"); try something like this[code] echo "<br /><br /><div align=center><span class='style2'>Error, Pleaes Enter The Correct Current Password</span></div><br />";echo "<input type=button value=back onclick=window.location='yourformpage.php'>";[/code]see how that works for you Quote Link to comment Share on other sites More sharing options...
romio Posted April 11, 2006 Author Share Posted April 11, 2006 [!--quoteo(post=363578:date=Apr 11 2006, 03:48 AM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Apr 11 2006, 03:48 AM) [snapback]363578[/snapback][/div][div class=\'quotemain\'][!--quotec--]instead of this header("Location: $_SERVER[PHP_SELF]"); try something like this[code] echo "<br /><br /><div align=center><span class='style2'>Error, Pleaes Enter The Correct Current Password</span></div><br />";echo "<input type=button value=back onclick=window.location='yourformpage.php'>";[/code]see how that works for you[/quote]in this way the refresh button will cause a problem ... user can still click on refresh. Quote Link to comment 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.