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] Link to comment https://forums.phpfreaks.com/topic/7095-showing-error-msg-aint-working-refresh-problem/ 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 Link to comment https://forums.phpfreaks.com/topic/7095-showing-error-msg-aint-working-refresh-problem/#findComment-25773 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. Link to comment https://forums.phpfreaks.com/topic/7095-showing-error-msg-aint-working-refresh-problem/#findComment-25804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.