Jump to content

showing error msg aint working, Refresh Problem.


romio

Recommended Posts

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]
<?php
require_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
Share on other sites

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
Share on other sites

[!--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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.