Jump to content

Archived

This topic is now archived and is closed to further replies.

romio

showing error msg aint working, Refresh Problem.

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]

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.