REGISTRATION FORM VALIDATION

Posted on Updated on

PHP-LOGIN FORM AND REGISTRATION FORM VALIDATION

In daily routine we come across many websites in which login page and registration page are the basic need. These pages can be created using various languages using JavaScript, PHP, JQuery, CSS, AJAX type languages.

The common thing among all the pages are validations and verifications.

Today we going to cover validations in registration and login pages in the backend with PHP.

Before starting the topic one must know about the types of validations we can use in PHP.

1. Required Field Validation: In this type of validation, user can’t left blank the fields on which validations are being applied. It is same as you can’t login to a website without entering username or password. Either it will generate an error message that required fields are empty.

2. Range Field Validation: In this type of validation, we can set the range of values which are accepted by the user. Like we know that Mobile number is of 10 digits and user can’t enter mobile number more or less than 10 digits, either an error message will be displayed that you have entered invalid number.

3. Data Type Validation: This type of validation is used to validate controls that either data entered by the user is matching to the data type demanded, either it won’t accept the wrong data type member or displayed correct message in correspond to that. In PHP it is done implicitly by the control. Like if some text box is used to demand age of a person so person is not allowed to alphabets into that text box.

4. Compare Validator: This type of validation is used to compare two value fields that whether they matches or not with each other. Like if someone demanding password on the page and have another text box for demanding reconfirmation of the password. If it doesn’t it may leads to inconsistency which is being removed by displaying an appropriate message to the user.

5. Custom Validation: This validation states that if user wants to apply its own logic on the value fields that are used on the webpage, then one can create custom validation. For example, user may apply validation on salary restricting user to enter salary in between 10000 t0 5000000.

Validation for Registration Form:

In this matter we are going to cover some validations on input fields like password field, confirm password fields, email fields, phone number etc.

We have to just take care of some of the following thing on registration forms:

1. No field should be left empty on Registration page.

2. Password field must matches to confirm password field.

3. Mobile numbers, Address, First Name, Last name should be considered mandatory for the form.

4. Only number terms will be entered into the mobile number field. No alphabets will be accepted.

5. Age must be 18+.

6. Email entered should be a valid email-ID.

7. If it’s so then your form will work seamlessly.

<html>

<head>

<head>

<body>

<form action=”<?php echo $_SERVER[‘PHP_SELF’];?>” method=”post”>

<input type=”text” name=”firstname” placeholder=”enter the user name”><br/>

<input type=”text” name=”father_name” placeholder=”enter the user Father name”><br/>

<input type=”text” name=”phone_num” placeholder=”enter the Phone Number”><br/>

<input type=”password” name=”Pas” placeholder=”enter the Password”><br/>

<input type=”password” name=”copassword” placeholder=”enter the confirm password”><br/>

<input type=”number” name=”age” placeholder=”enter the user age”><br/>

<textarea name=”address” placeholder=”Enter the user address”></textarea><br/>

<input type=”submit” name=”submit” value=”submit”>

</form>

<?php

if(isset($_POST[‘submit’]))

{

$name=$_POST[‘firstname’];

$father_name=$_POST[‘father_name’];

$phone_num=$_POST[‘phone_num’];

$pl=strlen($phone_num);

$password=$_POST[‘pas’];

$copass=$_POST[‘copassword’];

$age=$_POST[‘age’];

$address=$_POST[‘address’];

$adl=strlen($address);

if(!$name==””)

{

if(!$father_name==””)

{

if($pl==10)

{

if($password===$copass)

{

if($age>=18)

{

if($adl>=50)

{

echo “all conditions validate”;

}

else

{

echo “Address must contain 50+ words.<br/>”;

}

}

else

{

echo “age must be 18+ .<br/>”;

}

}

else

{

echo “Check the password.<br/>”;

}

}

else

{

echo “Enter the profect range.<br/>”;

}

}

else

{

echo “father name is empty.<br/>”;

}

}

else

{

echo “name is empty.<br/>”;

}

}

?>

</body>

</html>

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s