timwhelan Posted October 13, 2010 Share Posted October 13, 2010 Okay I am a beginner and haven't coded in months. I am trying to find a tutorial or help figuring out how to build a lost password script for user log-in system I built a while ago. Can anyone help with either something that works that I can learn from, a tutorial somewhere? thanks Tim Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/ Share on other sites More sharing options...
litebearer Posted October 13, 2010 Share Posted October 13, 2010 http://phpeasystep.com/phptu/21.html Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1121883 Share on other sites More sharing options...
timwhelan Posted October 14, 2010 Author Share Posted October 14, 2010 Thanks for the link. I followed all the steps. Everything acts like it is working - it processes the information - sends the email with passcode - and clicking the passcode process and deletes from the temp db table, however it doesn't write the new password to the old database table. Below is the code, am I missing something? The one thing I can question is I have a lot more fields in the db table that I want to write beside the first name, last name, password and userid - which is there email, would that be the problem? Thanks for helping!!! <? include('db.php'); // Passkey that got from link $passkey=$_GET['passkey']; $tbl_name1="temp_applicants"; // Retrieve data from table where row that match this passkey $sql1="SELECT * FROM $tbl_name1 WHERE confirmation_code ='$passkey'"; $result1=mysql_query($sql1); // If successfully queried if($result1){ // Count how many row has this passkey $count=mysql_num_rows($result1); // if found this passkey in our database, retrieve data from table "temp_applicants" if($count==1){ $rows=mysql_fetch_array($result1); $first_name=$rows['first_name']; $userid=$rows['userid']; $password=$rows['password']; $last_name=$rows['last_name']; $tbl_name2="astro_applicants"; // Insert data that retrieves from "temp_applicants" into table "astro_applicants" $sql2="INSERT INTO $tbl_name2(userid, password, first_name, last_name)VALUES('$userid', '$password', '$first_name', '$last_name')"; $result2=mysql_query($sql2); } // if not found passkey, display message "Wrong Confirmation code" else { echo "Wrong Confirmation code"; } // if successfully moved data from table"temp_applicants" to table "astro_applicants" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_applicants" if($result2){ echo "Your account has been activated"; // Delete information of this user from table "temp_applicants" that has this passkey $sql3="DELETE FROM $tbl_name1 WHERE confirmation_code = '$passkey'"; $result3=mysql_query($sql3); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122263 Share on other sites More sharing options...
elmas156 Posted October 14, 2010 Share Posted October 14, 2010 try changing this: <?php $sql2="INSERT INTO $tbl_name2(userid, password, first_name, last_name)VALUES('$userid', '$password', '$first_name', '$last_name')"; ?> to this: <?php $sql2=("INSERT INTO $tbl_name2(userid, password, first_name, last_name)VALUES('$userid', '$password', '$first_name', '$last_name')"); //added open and closed parenthesis before and after the open and closed quotes... ?> Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122269 Share on other sites More sharing options...
PFMaBiSmAd Posted October 14, 2010 Share Posted October 14, 2010 Given that a 'lost password' script would involve updating an existing user's password field, not INSERTing a new record for him, are you sure your script is attempting to do what you want? Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122275 Share on other sites More sharing options...
timwhelan Posted October 15, 2010 Author Share Posted October 15, 2010 elmas I haven't tried your method yet. I will... However, wanted to respond to PFMaBiSmAd - Since I am still a little new I am learning some proper procedures. Is there an UPDATE trigger versus an INSERT. Will start looking and will work to research if you can help point me in the right direction. If there are tutorials or links you can share I will read. I was initially following the link above to start figuring this out. Thanks again!!! Tim Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122334 Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2010 Share Posted October 15, 2010 http://w3schools.com/php/php_mysql_update.asp (this link is part of a whole basic php/mysql tutorial that you should probably read through.) Putting () around a string has no meaning and may even produce an error. Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122335 Share on other sites More sharing options...
timwhelan Posted October 15, 2010 Author Share Posted October 15, 2010 Right on. This is what I did. It took a few tries but I got it working. Thanks for dealing with a noob! Looking forward to more challenges. Peace - have a good weekend! Quote Link to comment https://forums.phpfreaks.com/topic/215804-lost-password-script/#findComment-1122495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.