Home > DeveloperSection > Forums > How to create program to validation in php
zack mathews
zack mathews

Total Post:23

Posted on    September-07-2016 7:13 AM

 PHP PHP  Validation 

 1 Reply(s)
 563  View(s)
Rate this:
Hi guys

I am beginner in php programming.Please explain me program code to validation in php.


Royce Roy
Royce Roy

Total Post:149

Posted on    September-07-2016 7:20 AM

Hi you can create script validation.php like this


//connection is made with database


$con = mysqli_connect("localhost","username",”password”, 'database name');


//when the form is submmited it will insert the values entered by user









//It will insert the value in database which is enterd by the user.

$con->query("insert into user_login values('$uname','$pass','$name','$dob',$phone)");



//client side validation


function validate()


//If any of the fields is left empty or null,this function will validate the fields and  alerts a message to returns false,to prevent the form being submitted

              var uname=document.forms["myForm"]["uname"].value;

             var uname=document.forms["myForm"]["pass"].value;

             var uname=document.forms["myForm"]["name"].value;

             var uname=document.forms["myForm"]["phone"].value;


   if(uname == null || uname == "" )


                         alert("Username must be filled.");

                         return false;


   if (document.getElementById('year').value == 'Select')


                        alert("Please select Year");

                       return false;


  else if (document.getElementById('month').value == 'Select')


                       alert("Please select Month");

                       return false;


   else if (document.getElementById('day').value == 'Select')


                       alert("Please select Day");

                       return false;





Don't want to miss updates? Please click the below button!

Follow MindStick