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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:50:37+00:00 2026-05-16T03:50:37+00:00

I am working on validating username, pass and email with php. I need to

  • 0

I am working on validating username, pass and email with php. I need to be sure I get it right so nobody can bypass the login page.

This is the values:

$email=$_POST['email'];
$username=$_POST['uname'];
$passwd=$_POST['pass'];
$passwd2=$_POST['passcopy'];

So far I have email validation:

if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email'])))
    die(msg(0,"You haven't provided a valid email"));

password equal:

if ($passwd != $passwd2) {
die(msg(0,"Passwords are not equal"));
}

password length:

if ((strlen($passwd) < 8) || (strlen($passwd) > 16)) {
die(msg(0,"Your password must be between 8 and 16 characters. Please type in a longer password"));
}

I know I need to validate the username. I was thinking only lowercase a-z0-9 to avoid people making similar usernames? Then password, what characters should I allow in a password?

PS. I still don’t understand preg_match and ereg. If somebody could explain this "/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+ and make a preg_match for my username and password validation it would be very helpful.

  • 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-16T03:50:38+00:00Added an answer on May 16, 2026 at 3:50 am

    the string ^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+ is a regular expression, that describes a pattern that you validate the email string against.

    Let me break the different parts down for you.

    ^ this indicates that the pattern should start matching at the beginning of the line.

    [\.A-z0-9_\-\+]+ this part is composed of two sub parts, first [\.A-z0-9_\-\+] that describes a class of characters, and then a + that indicates that you want one or more of the previous class.

    [@] matches exactly one @ sign.

    [A-z0-9_\-]+ another class of characters with a + after that means that you want one or more of the characters that are in the class.

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

Sidebar

Related Questions

hello sir in login page i am validating username and password from server database.
I can't seem to get client side validation working with the version of MVC
I'm using Tank Auth (it's working fine), but I can't get the form validation
I have a Register and login page both using unobtrusive ajax. The Username property
So I'm working on my login page modification again... and I'm running into another
I can't get client side validation of regular expressions working with MVC3RTM. All other
I'm working on a project and trying to use JavaScript for validating all inputs
I'm managed to get the validation working for the second step and third step
I am working on some simple form validation and need some assistance. Basically, I
My form is working fine with the validations being done by PHP. I have

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.