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 3679918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:30:55+00:00 2026-05-19T03:30:55+00:00

Hey guys, I have this sign up script and I’m using mysql_real_escape_string .I know

  • 0

Hey guys, I have this sign up script and I’m using mysql_real_escape_string .I know prepared statements are safer but I’m just not experienced enough to use them, I just can’t figure out how. Anyway here’s the script:

<?php

    $username=mysql_real_escape_string($_POST['username']);
    $password=sha1($_POST['password']);
    $password2=sha1($_POST['password_confirmation']);
    $passcheck=$_POST['password'];
    $todo=mysql_real_escape_string($_POST['todo']);
    $email=mysql_real_escape_string($_POST['email']);
    $fname=mysql_real_escape_string($_POST['fname']);
    $lname=mysql_real_escape_string($_POST['lname']);
    $gender=$_POST['gender'];
    $class=$_POST['class'];
    $section=$_POST['section'];



if(isset($todo) and $todo=="post"){

    $status = "OK";
    $msg="";
    }

if(!isset($username) OR strlen($username) <3){
    $msg=$msg."Username should be equal to or more than 3 characters long.<BR/>";
    $status= "NOTOK";
    }                   

if(mysql_num_rows(mysql_query("SELECT username FROM users WHERE username = '$username'"))){
$msg=$msg."Username already exists. Please try another one.<BR/>";
$status= "NOTOK";
}

if(mysql_num_rows(mysql_query("SELECT email FROM users WHERE email = '$email'"))){
$msg=$msg."E-mail is already in use. Please try again.<BR/>";
$status= "NOTOK";
}                                       


if ( strlen($passcheck) < 3 ){
    $msg=$msg."Password must be more than 3 charactors long.<BR/>";
    $status= "NOTOK";
    }                   

if ( $password <> $password2 ){
    $msg=$msg."Passwords are not identical.<BR/>";
    $status= "NOTOK";
    }                   
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
    $msg=$msg."The email is not a valid email.<br/>";
    $status="NOTOK";
    }

if($status=="NOTOK"){
    echo '<div class="statusmsg">'.$msg.'<br/><input class="submitButton" type="button" value="Retry" onClick="location.href='."'signup.php'\"></div>";
}
    else {
        $hash = md5( rand(0,1000) );
        $hash = mysql_real_escape_string($hash);
if(mysql_query("insert into users(username,password,email,fname,lname,hash,gender,class,section) values('$username','$password','$email','$fname','$lname','$hash','$gender','$class','$section')")or die (mysql_error ())){
    echo '<div class="statusmsg">Welcome, You have successfully signed up. Please check the verification e-mail sent to you.</div>';
    $to = $email; 
   $subject = 'Signup | Verification'; 
   $message = ' 

        Thanks for signing up! 
            Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below. 

            ------------------------ 
            Username: '.$username.' 
        ------------------------ 

        Please click this link to activate your account: 
   <div id="header">  
         <h3>JMToday > Sign up</h3>  
     </div>         
        http://www.JMtoday.com/verification.php?email='.$email.'&hash='.$hash.' 

   ';

    $headers = 'From:noreply@JMtoday.com' . "\r\n";  
    mail($to, $subject, $message, $headers); 
    }
else { 
echo "Database problem, please contact site admin";
}

}
?>
  • 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-19T03:30:56+00:00Added an answer on May 19, 2026 at 3:30 am

    The user will never see the “database problem” message, as the script will die() out if the query fails. As well, you’re embedding HTML into the message, but are not building a proper HTML-format email. Some mail clients may be smart enough to figure out there’s HTML and render it as such, but that’s just luck.

    The hash you generate is limited to generating only 1001 hashes. Given the birthday paradox, after 38 people sign up, the odds of a collision are 50%. After 100 people, the odds are 99.29%. Instead of hashing a random number, do something like:

    $hash = md5(serialize($_POST) . $some_other_stuff_in_case_POST_is_empty);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys - I know this is not a strictly programming question but I'm
Hey guys I need some help with this: I have two view controllers, let's
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey guys, I have this quick bit of code that I can't figure out
Hey guys I have a weird error I wrote this code against setbubblepopup $(document).ready(function
Hey right now I'm using jQuery and I have some global variables to hold
Hey guys I have a simple create method with some validations and whenever the
Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
Hey guys I have an assigned array from mysql results and I simply want
Hey guys I have a little issue here. I have a panel where I

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.