Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6706579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:32:13+00:00 2026-05-26T07:32:13+00:00

I am creating a forgotten password page and will be emailing a temporary password

  • 0

I am creating a forgotten password page and will be emailing a temporary password to the user so they can log in and reset their password.

What should I take into account when creating the password, what is the best method.

An idea I had is something like: $temporarypassword = sha1($_SERVER['REMOTE_ADDR'])

In an attempt to only allow them to login from the ip address where they requested the temp password. What is the best way to do this??

Code so far:

      if(strpos($_SERVER['HTTP_REFERER'],'domain.com') && ($_POST['forgotpasstoken'] == sha1($_SESSION['token'].'forgotpassword'))){
        if(isset($_POST['forgotemail']) && !empty($_POST['forgotemail'])){
            $email = mysql_escape_string(trim($_POST['forgotemail']));

            if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE){
                echo '<div class="error">Please enter a valid email address.</div>';
            } else {
                $sql = "SELECT email FROM users WHERE email = '$email' LIMIT 1";
                            $res = mysql_query($sql) or die(mysql_error());
                                if (mysql_num_rows($res) > 0) {

                                    //If email/user exists
            $temporarypassword = sha1($_SERVER['REMOTE_ADDR'])  
                //EMAIL PASSWORD HERE           

        echo '<div class="success">A temporary recovery password has been emailed to you.</div>';
                                    //If email/user exits
                                } else {
                                    echo '<div class="error">This email is not registered.</div>';
                        }
            }

        } else {
        echo '<div class="error">Please enter an email address.</div>'; 
        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:32:14+00:00Added an answer on May 26, 2026 at 7:32 am

    Use just a random string: it’s more than likely that user tries to log in from e.g. iPhone, fails, requests a new password, and only opens the link when he’s at his home PC. IPs are different, device is different, everything’s different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

creating a landing page that sends an email when people submit their address. I'd
When creating a forgotten password mechanism, we might want to create a tempory password
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a google map with store locations within 50 miles of user entered address.
Creating a server-side socket will fail if I'm trying to use the same port
When creating a web application, and lets say you have a User object denoting
Creating an installer for possible remote systems so that if they do not have
Creating a table without tbody using javascript createElement/appendChild will not add tbody in Firebug
Creating a popup window from main page with window.open, the child/popup page uses the
Creating a login page in xcode 4.2 I have the users fill out information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.