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

  • Home
  • SEARCH
  • 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 3234638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:24:53+00:00 2026-05-17T17:24:53+00:00

Hey all, I am creating a login script that in one step, enters the

  • 0

Hey all,
I am creating a login script that in one step, enters the new user into a text file, creates a new directory for that user, sends the user a code, and then the user has to enter the code to validate that he/she is real.
First question is about the code that is emailed:

a random number is created and sent to the new user. The new user in theory keeps his browser window open, and enters the code into the page. Once this happens, he clicks submit. I want to be able to compare the random number that was generated when the user created the account, to the one he received in the email using an IF statement.

$randNumber = rand();

<form id="form1" name="form1" method="post" action="">
 <span id="sprytextfield1">
   <label>Activation Code
     <input type="text" name="actcode" id="actcode" />
   </label>
   <span class="textfieldRequiredMsg">Please Enter Your activation Code To Continue.</span></span>
   <input name="Activate Account" type="submit" value="Activate Account" />

Something like: IF( $randNumber == 'actcode'){
redirect}
else{
     re-load}

How do I make the variable “$rand” which is created upon page load, compare to what the user enters when he hits “activate account”?

Thanks!

  • 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-17T17:24:54+00:00Added an answer on May 17, 2026 at 5:24 pm

    if you create a random number then it will always be random.. if the user closes the window he has to do the validation again,.

    it is better to create a hash (md5() or sha1()) of his email-id (+ any other details he provided) and mail it to him.

    if you want others not to predict the secret validation code then you better use some text manipulation on that hash.

    example:

    define a hash function

    function hashfunction( $username, $email)
    {
      return sha1($username).sha1($email);
    }
    
    $username = foo
    $email = bar@domain.com
    
    $hash = hashfunction( $username, $email)
    $url = "http://domainnname.com/verify.php?username=$username&email=$email&hash=$hash"
    @mail($email, "User Validation", $url)
    

    the generated url will be http://domainnname.com/verify.php?username=foo&email=bar@domain.com&hash=jr6u9ghj78gjkk76fv

    now you can verify the user by taking his username and email and running the same function to create hash and then comparing it with them hash in the url

    if (hashfunction($_GET['username'], $_GET['email']) == $_GET['hash'])
    {
       <validated>....
    }
    else
    {
      <not validated>....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, brand new to asp.net mvc and I am creating a fake social
Hey all - I have an app where I'm authenticating the user. They pass
Hey all, I'm pulling my hair out on this one. I've checked all my
Hey guys. I'm creating a rails app and being one of the first times
Hey there. I would really appreciate your help in creating a query that would
Hey all, I've created a loading/splash screen that loads at the beginning of my
Hey all, I'm writing a program that takes in a string representation of a
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey all, I have something of an interesting requirement for my project. I need

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.