PHP Form Handling

What is a Dynamic Website?

What is a Form?

Example

<html>

<head>
<title>PHP Form Validation</title>
</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>Web Design Tutorialz course registration form</h2>

<form method = "post" action = "/php/php_form_introduction.htm">
<table>
<tr>
<td>Name:</td>
<td><input type = "text" name = "name"></td>
</tr>

<tr>
<td>E-mail:</td>
<td><input type = "text" name = "email"></td>
</tr>

<tr>
<td>Specific Time:</td>
<td><input type = "text" name = "website"></td>
</tr>

<tr>
<td>Class details:</td>
<td><textarea name = "comment" rows = "5" cols = "40"></textarea></td>
</tr>

<tr>
<td>Gender:</td>
<td>
<input type = "radio" name = "gender" value = "female">Female
<input type = "radio" name = "gender" value = "male">Male
</td>
</tr>

<tr>
<td>
<input type = "submit" name = "submit" value = "Submit">
</td>
</tr>
</table>
</form>

<?php
echo "<h2>Your Given details are as :</h2>";
echo $name;
echo "<br>";

echo $email;
echo "<br>";

echo $website;
echo "<br>";

echo $comment;
echo "<br>";

echo $gender;
?>

</body>
</html>

Output

--

--

--

A tutorial blog that provides tutorials on Web Design, Programming, Java Technologies, Mobile App Development, Database, Machine Learning, etc.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Explore the possibilities with hundreds of domain extensions — {link} -

3D Model Editor Data Pack 1.15.2-1.14.4–3D Blocks Minecraft Vanilla — Wminecraft.net

3D Model Editor Data Pack 1.15.2–1.14.4

How To Drag And Drop CSV Files Directly To Google BigQuery, Amazon Redshift, and Athena

How to make popover from Menu Icon

Creating a Google Cloud Pub/Sub client using the Singleton design pattern in Golang

Test Automation Framework (Selenium with Java) — Awakening, or the First Selenium Test Case

Awesome Python Projects To Finish In a Weekend

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Web Design Tutorialz

Web Design Tutorialz

A tutorial blog that provides tutorials on Web Design, Programming, Java Technologies, Mobile App Development, Database, Machine Learning, etc.

More from Medium

How To Use PHP (Part 3)

How To Convert PHP String to Array — Phpflow.com

PHP functions strcspn() and strspn()

Adding Custom Global Arguments to Artisan Commands