Lab #4

2. Create a form using a text box, check box, radio button, select, submit button. And display user inserted value in a new PHP page (e.g. student registration/inventory/library form).


<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Buy Courses</title>

margin: 10px 0;
<div class="container">
<form action="result.php" method="post">
<div class="form-input">
<input type="text" name="name" placeholder="Enter full name">

<div class="form-input">
<input type="number" name="age" min="10" max="164" placeholder="Enter age">

<div class="form-input">
<label for="courses">Select courses</label>
<select name="courses" id="courses">
<option value="java">Java</option>
<option value="python">Python</option>
<option value="c">C</option>
<option value="c++">C++</option>
<option value="javascript">JavaScript</option>
<option value="php">PHP</option>

<div class="form-input">
<input type="radio" name="gender" value="male" id="male">
<label for="male">Male</label>

<input type="radio" name="gender" value="female" id="female">
<label for="female">Female</label>

<div class="form-input">
<input type="checkbox" name="tac" id="tac">
<label for="tac">Accept <a href="#">terms and conditions</a></label>

<div class="form-input">
<button type="submit">Submit</button>


echo "Name: ".$_POST['name'].'<br/>';
echo "Age: ".$_POST['age'].'<br/>';
echo "Email: ".$_POST['email'].'<br/>';
echo "Course: ".$_POST['courses'].'<br/>';
echo "Gender: ".$_POST['gender'].'<br/>';


The output of first page  (the simple registration form)

After clicking on Submit button

Happy coding :)