PHP Form Validation

PHP Form Validation In Hindi – Form Validation In Hindi

PHP

PHP Form Validation In HindiForm Validation In Hindi:- PHP Main Validation Karna Ek Secure Way Hota Hain Lekin Ye All Programming Language Mai Hi Form Ko Secure Karne Ke Liye Form Validation Ka Istemal Hota Hain |

PHP Form Validation In Hindi

Required Field Check Karta Hain Ki Jo Field Form Main Di Gayi Hain Wo Proper Way Main Filled Kari Hain Ya Nhi. Lekin Most of Cases Mai Ham Istemal Karte Hain * symbol for the required field.

What is Validation in Hindi ?

Validation Chack Karta Hain Ki User Jab Data Ko Input Karta Hai Or Uske Bad Jab User submitted Karta Hai To Validation Hota Hain |

Validation PHP Mai Two Types Ki Hoti Hain |

  • Client-Side Validation − Validation performed Karta Hain client machine web browsers Par.
  • Server-Side Validation − Data Submitted Hone Ke Bad, Data Sent Hota Hain Sever Par Or fir Server Machine Checks Karti Validation Ko |

Some of Validation rules for field in PHP

FieldValidation Rules
NameShould required letters and white-spaces
EmailShould required @ and .
WebsiteShould required a valid URL
RadioMust be selectable at least once
Check BoxMust be checkable at least once
Drop Down menuMust be selectable at least once

Example With PHP Validation :

<!DOCTYPE HTML>  
<html>
<head>
</head>
<body>  

<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $name = test_input($_POST["name"]);
  $email = test_input($_POST["email"]);
  $website = test_input($_POST["website"]);
  $comment = test_input($_POST["comment"]);
  $gender = test_input($_POST["gender"]);
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
?>

<h2>PHP Form Validation Example</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  Name: <input type="text" name="name">
  <br><br>
  E-mail: <input type="text" name="email">
  <br><br>
  Website: <input type="text" name="website">
  <br><br>
  Comment: <textarea name="comment" rows="5" cols="40"></textarea>
  <br><br>
  Gender:
  <input type="radio" name="gender" value="female">Female
  <input type="radio" name="gender" value="male">Male
  <input type="radio" name="gender" value="other">Other
  <br><br>
  <input type="submit" name="submit" value="Submit">  
</form>

<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>

</body>
</html>

Output:

PHP Form Required In Hindi

Example With HTML Required Function:

Ham Keval Input Field Main required Function ko Likh Kar Validation Karne Wale Hain Wo Bhi HTML Required Function Ki Help Se |

<!DOCTYPE html>
<html>
<head>
	<title>PHP Tutorial Validation</title>
</head>
<body>


	<form method="post">
		<h1>Validation With HTML</h1>
		Name :<input type="text" name="fname" required> <span>*</span><br>
		<br>
		Mobile No :<input type="number" name="mobile" required><span>*</span><br>
		<br>
		Email Id :<input type="email" name="email"required><span>*</span><br>
		<br>
		<input type="submit">
	</form>


		<?php
			if($_SERVER['REQUEST_METHOD'] == 'POST'){
				$name = $_POST['fname'];
				$mobile = $_POST['mobile'];
				$email = $_POST['email'];
				echo "<br>";
				echo "Your Name is $name And Your Mobile Number Is $mobile And Your Email Is $email";
			}
		?>
</body>
</html>

Output With Out Enter Input Field:

Aap Upper Diye Gaye Output Ko Check Kar Sakte Hain Jab Main emial id Ko Bina Dale Submit Button Par Click Kiya To Usne Validation Check Or Output Main Usne show Kar diya Please Fill Out This Field.

Output With Enter Input Field:

Sab Input Field Ko Enter Karne Ke Bad |

Yadi Aapne  HTML Full Course  And CSS Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Friends Mujhe Umeed Hai Ki Aapko Form Validation In PHP in Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *