BIS 3043 Lecture 2
BIS 3043 Lecture 2
BIS 3043 Lecture 2
<form>
<input type="radio" name="sex" value="male"> Male
<br>
<input type="radio" name="sex" value="female"> Female
</form>
Checkboxes
Checkboxes are used when you want the user to select one
or more options of a limited number of choices.
Example-20
<form>
I have a bike:
<input type="checkbox" name="vehicle" value="Bike">
<br>
I have a car:
<input type="checkbox" name="vehicle" value="Car">
<br>
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane">
</form>
The Form's Action Attribute and the Submit Button
<body>
<form >
<select name="cars">
<option value="800"> Maruthi 800</option>
<option value="Alto">Maruthi ALTO</option>
<option value="Wagonor">Maruthi Wagonor</option>
<option value="Swift">Maruthi Swift</option>
</select>
</form>
</body>
</html>
PHP Form handling
The most important thing to notice when dealing with HTML forms and
PHP is that any form element in an HTML page will automatically be
available to your PHP scripts.
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html> Welcome.php
<html>
<body>
Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html
The $_GET Variable
The $_GET variable is an array of variable names and values sent by the
HTTP GET method.
The $_GET variable is used to collect values from a form with method="get".
Information sent from a form with the GET method is visible to everyone (it
will be displayed in the browser's address bar) and it has limits on the amount
of information to send (max. 100 characters).
You can insert the content of a file into a PHP file before the server
executes it, with the include() or require() function
The two functions are identical in every way, except how they
handle errors.
Example
<html>
<body>
<?php include("header.php"); ?>
<h1>Welcome to my home page</h1>
<p>Some text</p>
</body>
</html>
<html>
<body>
Menu.php <a href="default.php">Home</a> |
<a href="about.php">About Us</a> |
<a href="contact.php">Contact Us</a>
</body>
</html>