dhanasekar Posted February 16, 2012 Share Posted February 16, 2012 hi... i am very new to php.... i need to create new password generation in php, i have created password new generation with great struggle.. when i click on load button ... it fetches all the data what in needed... for ex password:123112 , when i click on generate password button...a new password should replace on my oid password for ex password:ADADA... <?php if(!isset($_POST['gpass'])) { $newcode_length=0;$newcode=0;$codelenght = 8;while($newcode_length < $codelenght) {$x=1;$y=3;$part = rand($x,$y);if($part==1){$a=49;$b=57;} // Numbersif($part==2){$a=65;$b=90;} // UpperCaseif($part==3){$a=97;$b=122;} // LowerCase$code_part=chr(rand($a,$);$newcode_length = $newcode_length + 1;$newcode = $newcode.$code_part;}} ?> have wrote sum thing like this ...but generate password button didnt work..pl help some one...thanks in advance Link to comment Share on other sites More sharing options...
justsomeguy Posted February 16, 2012 Share Posted February 16, 2012 That should generate the password fine, but that code doesn't do anything with the password you've generated. Link to comment Share on other sites More sharing options...
dhanasekar Posted February 18, 2012 Author Share Posted February 18, 2012 Hi.. i am very new to php. pl help me, after clicking on submit button to generate password as well as update this new password should replace ma password column in database...pl give me some code.. thanks in advance Link to comment Share on other sites More sharing options...
justsomeguy Posted February 20, 2012 Share Posted February 20, 2012 There are examples of update statements here: http://www.w3schools.com/sql/sql_update.asp I'm not sure how your application accesses the database, so you'll need to figure that out first. Once you know that then you can use the $newcode variable to update the password in the database as long as you have the ID of the user to update. That ID may have been passed through the form or it may be stored in the session or somewhere else. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.