Form Validation
Form Validation
Sign up
Raghavendraprasad1
php-tutorial
Public
Code
Issues
Pull requests
Actions
Projects
Security
Insights
php-tutorial/form_validation.php
@Raghavendraprasad1
1 contributor
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"
crossorigin="anonymous"></script>
<title>Registration</title>
<style type="text/css">
.error {
font-size: 15px;
color: red;
</style>
</head>
<body>
<?php
$flag = true;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["firstname"])) {
$flag = false;
} else {
$firstname = test_input($_POST["firstname"]);
if (empty($_POST["lastname"])) {
$flag = false;
} else {
$lastname = test_input($_POST["lastname"]);
if (empty($_POST["phone"])) {
$flag = false;
} else {
$phone = test_input($_POST["phone"]);
if (empty($_POST["email"])) {
$flag = false;
} else {
$email = test_input($_POST["email"]);
$country = $_POST["country"];
$state = $_POST["state"];
if ($flag) {
if ($conn->connect_error) {
function test_input($data)
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
?>
font-style: italic;">
<header>Registration Form</header>
</div>
<div class="card-body">
</div>
</div>
</div>
</div>
</select>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
Footer
Footer navigation
Terms
Privacy
Security
Status
Docs
Contact GitHub
Pricing
API
Training
Blog
About