Forum Moderators: coopster

Message Too Old, No Replies

Need a Password change script for this MYSQL DB.

password change php scrip required for mysql db

         

neo4495

12:11 pm on Jul 30, 2010 (gmt 0)

10+ Year Member



Hi there,
i am really a newbee in this,
if some one could tell me what would be the passwordf change php script for this mysql db

CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

--
-- Dumping data for table `members`
--

INSERT INTO `members` VALUES (1, 'john', '1234');

Matthew1980

12:58 pm on Jul 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there neo4495,

Welcome to the forum :) [webmasterworld.com ]

Are you referring to adding a user with the chars encoded for the password (md5(), sha1())?

if so:-

INSERT INTO `members` (`id`, `username`, `password`) VALUES ('1', 'john', md5('1234'));

That looks right anyway ;)

Check out the mysql website for more info: [dev.mysql.com ]

Cheers,
MRb

neo4495

1:21 pm on Jul 30, 2010 (gmt 0)

10+ Year Member



can you give me a php script for it... as i said i am a newbee.

Matthew1980

2:08 pm on Jul 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there neo4495,

I haven't got time to do a script for you, and generally we can only give advice on things like this, to give you an idea, you will need the following:-

  • A form with the relevant text fields username & password etc.
  • the process script to deal with the data sent
  • The inserted screen of success (if you want one:))

    The Html

    <form action="processData.php" method="post">
    <p>Choose username:<input type="text" name="username"></p>
    <p>Choose Password:<input type="text" name="password_1"></p>
    <p>Confirm Password:<input type="text" name="password_2"></p>
    <p><input type="submit" name="submit" value="insert user!"></p>
    </form>

    The php process script

    call it the same as the file reference in the action attribute :)

    <?php
    if(isset($_POST['submit']) && ($_POST['submit'] == "insert user!")){
    //perform form checks & check passwords match
    if(strcmp($_POST['password_1'], $_POST['password_2']) != "0" ){
    echo "passwords don't match";
    exit;
    }
    //clean submitted data
    $_POST = array_map('strip_tags', $_POST);

    //if that's successful go to the insert part :)

    $sql = "INSERT INTO `tableName`... etc etc";//insert sql
    $SqlSuccess = mysql_query($sql, $YOUR_CONNECTION_HANDLE) or die(mysql_error());

    if($SqlSuccess){
    echo "update successful";
    //send user back to form after little delay :)
    header( "refresh:5; url=yourFormPage.php" );
    exit;
    }
    else{
    echo "error entering info";
    exit;
    }
    }
    else{
    echo "processing error";
    exit;
    }
    ?>

    These are just as guide's, and typed on the fly, so a could have error's. Also this is quite minimal & doesn't do any sql_cleaning, but I think, get the script functional first, then tweek it.

    Hopefully this will point you in the right direction for doing your script.

    Hope this helps :)

    Cheers,
    MRb
  • neo4495

    2:32 pm on Jul 30, 2010 (gmt 0)

    10+ Year Member



    thanks a lot friend, it was most helpfull, i m sorry for being so dum! lolz

    Matthew1980

    2:42 pm on Jul 30, 2010 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    hi there neo4495,

    Lol. Not dumb, just learning, we all start at the same place :)

    Cheers,
    MRb