Results 1 to 6 of 6

Thread: Change Password

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Change Password

    Is there any bugs in the following script?My script always execute on else part.Thanks...

    PHP Code:
    <?php
    include ('dbconn.cfg');// database configuration file
    $connection = @mysql_connect("localhost""root""") or die("Cannot connect to server!");
    if (isset(
    $_SESSION['gmemberid']))
    {

        
    $tbl_name "member";
        
    $sql "SELECT password FROM $tbl_name";

        
    $result = @mysql_query($sql$connection) or die("Cannot execute query.");
        if (isset(
    $_POST['changePw']))
        {
            if (
    $result == $_POST['oldPw'])
            {
               
    $update mysql_query("
                          UPDATE 
                               
    $tbl_name
                          SET
                               password = '" 
    mysql_real_escape_string($_POST['newPw1']) . "',
                          
                          WHERE
                               password = '" 
    mysql_real_escape_string($_REQUEST['password']) . "',
                  
                          "
    );
                        echo(
    $update);
                           exit();
                        
    $changed mysql_query($update) or die(mysql_error());
                  
                
    //$result = $_POST['newPw1'];
                
    $redirectUrl "http://localhost/www2/home.html";
                print 
    "<script type=\"text/javascript\">";
                print 
    "window.location.href = '$redirectUrl'";
                print 
    "</script>";
            }
            else
            {
                
    $status "Wrong Old Password!";// wrong old password
            
    }


        }


    }
    ?>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    mysql_query() returns a result set, which is never going to be equal to a string.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    mysql_query() returns a result set, which is never going to be equal to a string.
    Thanks for reply. I am using mysql_result rather than mysql_query now
    PHP Code:
    $oldPw mysql_result($result,0);
        if (isset(
    $_POST['changePw']))
        {
            if (
    $oldPw == $_POST['oldPw'])
    .... 
    If the page can't execute javascript to redirect, is it mean that having problem in session?I not yet link changePW page to login page together.If after login then I open changePW in another window,will sesion to be continued in the new window?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I'm sorry, I didn't understand your question. Can you rephrase?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    I'm sorry, I didn't understand your question. Can you rephrase?
    Simply mean that I can only change password after login but now do these 2 tasks in different windows,can the session that contain login data being passed through windows?

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, the session will exist on any request made after the session was established.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •