SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Still not working

    I have been tryin to get my password change script working all day. With the help of seanf and others i have got rid of an annoying error. The only problem is that it isnt updating the pass. I submit the form and check phpMyAdmin and the pass is still the same. Can some one make my day and see whats wrong. Ive spent all day trying to get this sorted and i dont want it to go to waste.
    PHP Code:
    <?php

        $db 
    mysql_connect("localhost""mech""*****") or die(mysql_error());

        
    mysql_select_db("mech") or die(mysql_error());

        if ( 
    $update == "yes" ) {

            
    $sql mysql_query("UPDATE user SET password='$newpassword' WHERE userid='$userid'") or die(mysql_error());

        }

    ?>

    <html>
    <head><title>User Password Change</title></head>
    <body>
    <h3>Password Change</h3>
    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
       When you have changed your password you will have to re login with the new one.</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
        <tr>
            <td align=right>
                <p>New Password</p>
            </td>
            <td>
                <input name=newpassword type=text maxlength=100 size=25>
    <input type=hidden name=update value=yes>
    <input type=submit name="submitok" value="Change">
        </tr>
    </table>
    </form>
    </body>
    </html>
    It brings up no error,,just does a quick refresh and thats it. Its very annoying aaaaaarrrrggggggghhhhhh

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There was no need to create a new thread for this, you could have continued in the same thread, where Matt has just posted!

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorry

    its just i thought it would get noticed better,,,i really need to get this sorted out.

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To start you have a HTML error:

    <input type=hidden name=update value=yes>

    Should be:

    <input type="hidden" name="update" value="yes">

    This could be the source of the problem

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) You didn't need to repost this.

    2) I think you are better off doing this:

    PHP Code:
    <?php

    if(isset($submitok)) {

        
    $db mysql_connect("localhost""mech""*****") or die(mysql_error());

        
    mysql_select_db("mech") or die(mysql_error());

        if (
    $update == "yes") {

            
    $sql mysql_query("UPDATE user SET password='$newpassword' WHERE userid='$userid'") or die(mysql_error());

        }
    }
    ?>
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  6. #6
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by seanf
    There was no need to create a new thread for this, you could have continued in the same thread, where Matt has just posted!

    Sean
    How come you are always one step ahead of me?!
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  7. #7
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm actually a little person who lives in your computer, if you look closely you might see me!

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup,

    weirdbearddmt should have it,

    Straight from Kevins book and pretty as can be it should indeed work. By the sean did point out a good thing. Check all of your "" '' or ; before you loose your mind. PHP is not very nice if you leave that important parts out!
    But I'm learning as fast as I can!!!

  9. #9
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    its still the same

    just does the quick refresh still,,i used both of your ideas, but no luck

  10. #10
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) Are you including accesscontrol.php (or whatever it is called) in your file? If not then it won't work since the session variables will be lost.

    2) Try this:

    PHP Code:
    <?php

    if(isset($submitok)) {

        
    $db mysql_connect("localhost""mech""*****") or die(mysql_error());

        
    mysql_select_db("mech") or die(mysql_error());

        
    $sql mysql_query("UPDATE user SET password='$newpassword' WHERE userid='$userid'") or die(mysql_error());

        
    }
    ?>
    <html>
    <head><title>User Password Change</title></head>
    <body>
    <h3>Password Change</h3>
    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
       When you have changed your password you will have to re login with the new one.</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
        <tr>
            <td align=right>
                <p>New Password</p>
            </td>
            <td>
                <input name="newpassword" type="text" maxlength=100 size=25>
    <input type=submit name="submitok" value="Change">
        </tr>
    </table>
    </form>
    </body>
    </html>
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  11. #11
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey people,

    Check to make sure the variable is being set...

    I.E. echo"$newpassword"; whereby the $ is whatever you are updating.

    Quite often on a ?PHP_SELF
    you can never know because it will pass an empty query.

    Make sure the variable is being set then re-implement the code by weirdbearddmt.

    I have done this very code and it will work.
    But I'm learning as fast as I can!!!

  12. #12
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops forgot to mention something.

    If you add softened error statements you will save yourself a lot of trouble.

    instead of mysql_connect...

    try making the statement die quitely with @ sign and then retrieve something friendlier.
    <?
    $connect = @msql_query("Update mech Set password='$newpassword' where userID='$userID');

    if(!connect){
    echo("no connection was made . mysql_error()");
    }
    ?>

    I think that is right...
    But I'm learning as fast as I can!!!

  13. #13
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ok

    so if i was to add the above, where would i insert it into my script. This might save me some time - thanx

  14. #14
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird

    ok i have got the script working but theres one problem. The password doesnt change unless the submit button is clicked 2 times. I used the following code:
    PHP Code:
    <?php include("accesscontrol.php"); ?>
    <?php

    if(isset($submitok)) {

        
    $db mysql_connect("localhost""mech""*****") or die(mysql_error());

        
    mysql_select_db("mech") or die(mysql_error());

        
    $sql mysql_query("UPDATE user SET password='$newpassword' WHERE fullname='$username'") or die(mysql_error());


    ?> 

    <html>
    <head><title>User Password Change</title></head>
    <body>
    <h3>Password Change</h3>
    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
       When you have changed your password you will have to re login with the new one.</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
        <tr>
            <td align=right>
                <p>New Password </p>
            </td>
            <td>
                <input name="newpassword" type="text" maxlength=100 size=25>
    <input type=submit name="submitok" value="Change">
        </tr>
    </table>
    </form>
    </body>
    </html>
    Anyone got any ideas as to why it needs to be clicked 2 times.

  15. #15
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure if this will do anything, bit try it any way

    <input type=submit

    to

    <input type="submit"

    other than that it must be

    if(isset($submitok)) {

    ive never used it that way to submit, i use

    if($submitok) {

    hth
    http://redgoals.com ... my site ... nuff said

  16. #16
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $submitok

    You could also use...

    <html>
    <head><title>User Password Change</title></head>
    <body>
    <h3>Password Change</h3>
    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
    When you have changed your password you will have to re login with the new one.</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
    <tr>
    <td align=right>
    <p>New Password </p>
    </td>
    <td>
    <input name="newpassword" type="text" maxlength=100 size=25>
    <input type=submit name="submitok" value="Change">
    </tr>
    </table>
    </form>
    <?php include("accesscontrol.php"); ?>
    <?php

    if($submitok == "Change") {

    $db = mysql_connect("localhost", "mech", "*****") or die(mysql_error());

    mysql_select_db("mech") or die(mysql_error());

    $sql = mysql_query("UPDATE user SET password='$newpassword' WHERE fullname='$username'") or die(mysql_error());

    }
    ?>

    </body>
    </html>

    That is how I do the script and it has worked very well for me. (Thanks again to Kevin Yank!)
    But I'm learning as fast as I can!!!

  17. #17
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ok

    it updates with one click now but it brings up the following error:Warning: Cannot send session cache limiter - headers already sent (output started at /home/mech/public_html/passwordchange.php:7) in /home/mech/public_html/accesscontrol.php on line 6.
    I have included my accesscontrol below just incase.
    PHP Code:
    <?php // accesscontrol.php

    include("common.php");
    include(
    "db.php");

    session_start();

    if(!isset(
    $uid)) {
      
    ?>
      <html>
      <head>
      <title> Please Log In for Access to Mech Recon </title>
      </head>
      <body bgcolor="#000000" text="#7F9FCF" link="#ffffff" vlink="#ffffff" alink="#ffffff" topmargin="0" leftmargin="0">
      <body>
      <h1> Login Required </h1>
      <p>You must log in to access Mech Recon. If you are
         not a registered user, <a href="game.php">click here</a>
         to sign up for instant access!</p>
      <p><form method="post" action="<?=$PHP_SELF?>">
        User ID:<br><input type="text" name="uid" size="8" style="background:#000000; color:#ffffff;font-family:arial;border-style:dashed; border-width:1px; border-color:#0D38F0">
    <br>
        Password:<br><input type="password" name="pwd" SIZE="8" style="background:#000000; color:#ffffff;font-family:arial;border-style:dashed; border-width:1px; border-color:#0D38F0"><br>
        <input type="submit" value="Log in"
    style="background:#000000; color:#ffffff;font-family:arial;border-style:dashed; border-width:1px; border-color:#0D38F0">
    </form></p>
      </body>
      </html>
      <?php
      
    exit;
    }

    session_register("uid");
    session_register("pwd");

    dbConnect("mech");
    $sql "SELECT * FROM user WHERE
            userid = '
    $uid' AND password = '$pwd'";
    $result mysql_query($sql);
    if (!
    $result) {
      
    error("A database error occurred while checking your ".
            
    "login details.\\nIf this error persists, please ".
            
    "contact [email]lance_evans12@hotmail.com[/email]");
    }

    if (
    mysql_num_rows($result) == 0) {
      
    session_unregister("uid");
      
    session_unregister("pwd");
      
    ?>
      <html>
      <head>
      <title> Access Denied </title>
      </head>
      <body bgcolor="#000000" text="#7F9FCF" link="#ffffff" vlink="#ffffff" alink="#ffffff" topmargin="0" leftmargin="0">
      <body>
      <h1> Access Denied </h1>
      <p>Your user ID or password is incorrect, or you are not a
         registered user of Mech Recon. To try logging in again, click
         <a href="<?=$PHP_SELF?>">here</a>. To register for instant
         access, click <a href="signup.php">here</a>.</p>
      </body>
      </html>
      <?php
      
    exit;
    }
    $email mysql_result($result,0,"email"); 
    $username mysql_result($result,0,"fullname");
    $level mysql_result($result,0,"level");
    $hp mysql_result($result,0,"hp");
    $dce mysql_result($result,0,"dce");
    $crystals mysql_result($result,0,"crystals");
    $strength mysql_result($result,0,"strength");
    $speed mysql_result($result,0,"speed");
    $agression mysql_result($result,0,"agression");
    $intelligence mysql_result($result,0,"intelligence");
    $endurance mysql_result($result,0,"endurance");
    $age mysql_result($result,0,"age");
    $items mysql_result($result,0,"items");
    $rank mysql_result($result,0,"rank");
    $weapons mysql_result($result,0,"weapons");
    $quote mysql_result($result,0,"quote");
    ?>
    I would just like to thank you guys for even gettin me this far as i would have given up by now.

  18. #18
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    try

    try throwing the session start before your includes...

    Just a guess but things get nasty sometimes when you have something before your session start and that is the warning you get when that occurs.
    But I'm learning as fast as I can!!!

  19. #19
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no luck

    i switched the two and i get the error :Warning: Cannot send session cache limiter - headers already sent (output started at /home/mech/public_html/passwordchange.php:7) in /home/mech/public_html/accesscontrol.php on line 3

  20. #20
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can u confirm which code u are using in passwordchanger.php? is it the one provided by pcpresents?

    because if it is then there may be an error with it.

    im refering to how low down the file accesscontrol.php is included in that code.
    http://redgoals.com ... my site ... nuff said

  21. #21
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when you use <?=$PHP_SELF?> remember that when it reloads it will not have all of the original information unless you post that information on the refresh.

    i.e. if I am using a password check for the page and i use <?=$PHP_SELF?> I have to send the password and username with the "post" or have it stored as a session variable so that the page can retrieve it again.

    I don't know if this is the problem but that is one that gave me a hemorrage for a while.

    I hope that helps but I am really not sure.

    It seems it is accessing two pages is that correct?

    password.php and access control.php?
    But I'm learning as fast as I can!!!

  22. #22
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Windsor, Ontario, Canada
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually redgoals I just copied that from the code he provided us.

    I only suggested the

    if ($submit == "Change"){

    for the submission.

    I'm not too familiar with the rest of it to be honest.
    But I'm learning as fast as I can!!!

  23. #23
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php include("accesscontrol.php"); ?>

    needs to be at the top of the page.

    if he used your code where the include is lower down the page then he's bound to get that error.
    http://redgoals.com ... my site ... nuff said


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
  •