Jump to content

Lost Password script


timwhelan

Recommended Posts

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

Link to comment
Share on other sites

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);

}

}
?>

Link to comment
Share on other sites

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...
?>

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.