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

The Archive Base Latest Questions

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

I have a registration form on my website and need to validate the input

  • 0

I have a registration form on my website and need to validate the input before creating the account. I have read that javascript validation can be easily disabled so I have opted for php.

I am having issues linking the different validations using ‘and’ not quite sure what is going wrong.

if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
                    // Return Error - Invalid Email
                    $msg = 'Please enter a valid email address.';
                } and (!preg_match("/\S+/", $firstname)){
      // Return Error - Firstname blank
                    $msg = 'Please enter your first name.';
  } and (!preg_match("/\S+/", $lastname)){
      // Return Error - Lastname blank
                    $msg = 'Please enter your last name.';
  }(!preg_match("/.{6,}/", $password)){
  // Return Error - password short
                    $msg = 'The password entered is too short. Please use 6 or more characters.';
  }

                else{ //submit form

Is there anything I am missing from the validation that a more experienced coder would use?

Hope you can help a newbie like me…

  • 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:40:43+00:00Added an answer on May 26, 2026 at 7:40 am

    I didn’t check your Regular expressions, but here is a redefined version of your code:

    $msg ="";
    if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
        // Return Error - Invalid Email
        $msg = 'Please enter a valid email address.';
    }else if(!preg_match("/\S+/", $firstname)){
        // Return Error - Firstname blank
        $msg = 'Please enter your first name.';
    }else if(!preg_match("/\S+/", $lastname)){
        // Return Error - Lastname blank
        $msg = 'Please enter your last name.';
    }else if((!preg_match("/.{6,}/", $password))){
        // Return Error - password short
        $msg = 'The password entered is too short. Please use 6 or more characters.';
    }else if($msg == ""){
    
    //Submit form
    

    This is a very simple way of doing things, but I recommend taking a few tutorials of validating techniques register forms next time.
    Here are a few good tutorials:
    http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/
    Video part 1:
    http://www.youtube.com/watch?v=t8ehovDeMuU
    Video part 2:
    http://www.youtube.com/watch?v=FlwlpRQo6II

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

Sidebar

Related Questions

I'm creating a registration form on my school project website. I have given a
I have a registration form for a website that needs to check if an
I have written a Silverlight application that is basically an account registration form. I
I have registration form on my website that, using jquery I append default values
We have a simple registration form for our website users where we only require
I have a registration form leveraging xVal to handle all validation on the form.
I have a product registration form that allows the user to add additional product
I have a basic form that I'm using for member registration. I'm using the
I have a registration form that when the user enters in valid registration data
Team I'm creating an iphone application using Sencha Touch. I have registration form ,

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.