hide the password in the link

add to this the ability to hide the password in the email
and to assign a new random password if the user clicks on the link
  $host="localhost"; //Host name
  $username="root"; //mysql username
  $password=""; //mysql password
  $db_name="hello"; //database name
  //connect to server and select database.
  mysql_connect("$host","$username","$password") or die ("cannot connect to server");
  mysql_select_db("$db_name") or die ("cannot select db");
  //value sent from form
  //table name
  //retrieve passwords from table where email=$email_to(mark@phpeasystep.com)
  $sql="SELECT password FROM $tbl_name where email='$email_to'";
  //if found this e-mail address, row must be 1 row
  //keep value in variable name "$count";
  // compare if $count=1 row
    //keep password in $your_password
    //---send mail form----
    //send e-mail to ...
    //your subject
    $subject="Your password here";
    $header="from:your name <your email>";
    //your message
    $messages="Your password for login to our website \r\n";
    $messages.="Your password is $your_password \r\n";
    $messages.="more message..\r\n";
    //send email
    //echo $messages;
  //else if $count not equal 1
    echo "Not found your email in our database";
  //if your email succesfully sent
    echo "Your Password has been sent to your email address.";
    echo "Cannot send passwords to your e-mail address";

Open in new window

<table width="380" border="0" cellpadding="3" cellspacing="1">
<td width="33%"><strong>Enter your email: </strong></td>
<td width="67%"><form name="form1" method="post" action="send_password_ac.php">
<input name="email_to" type="text" id="mail_to" size="25">
<input type="submit" name="Submit" value="Submit">




Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I do not recommend you to expose the user's password in the link. To reset password, you should apply some way else.

For example, generate a unique one time key when the user requests to reset the password and send it to his email. Once user clicks the link with his email address and one time key, create a random password for the record matched the one time key and email address and remove one time key from the database.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
for resetting password.
 provide an email for his approval .
When he clicks to it provide him option to display the password there it self or to get a email
If he wants to see it there itself he can view it or it would be fine if we send him password via email.

Flow would be
                       reset password
1> USER      ---------------------------->    SERVER
2> USER      <-----------------------------   SERVER
                      Email for confirmation
3>   USER     ---------------------------->    SERVER

4> USER      <-----------------------------   SERVER
                      password  display / email
AlexSoftware EngineerCommented:
Hello rgb192,

If you want to use that for a "forgot password reminder" I don't think that it's a good idea to "hide" it as you said. You have to create a new one, usually an md5 unique string based on email plus a salt and at the end cut some characters of the whole final string and update the password. That will be his/her new password until they updated again via their personal settings.
rgb192Author Commented:
all work, thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.