0% found this document useful (0 votes)
2 views

Module 4

The document outlines PHP programs demonstrating form handling using GET, POST, and REQUEST methods, including example HTML forms and corresponding PHP scripts to retrieve and display username and password inputs. It also illustrates the use of include() and require() functions in PHP with examples of including HTML and PHP files. The document includes outputs for each example to show the results of the executed scripts.

Uploaded by

fastestbhau18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Module 4

The document outlines PHP programs demonstrating form handling using GET, POST, and REQUEST methods, including example HTML forms and corresponding PHP scripts to retrieve and display username and password inputs. It also illustrates the use of include() and require() functions in PHP with examples of including HTML and PHP files. The document includes outputs for each example to show the results of the executed scripts.

Uploaded by

fastestbhau18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Module No:04 Date: 07-01-2025

a)Develop a PHP program to illustrate the PHP Form handling by using GET and POST
methods.

i)By using “GET” method:

<!DOCTYPE html>

<html lang="en">

<head>

<title>Simple Login Page</title>

</head>

<body>

<h1>Login Page</h1>

<form name="fn" method="GET" action="get.php">

<label for="username">Username:</label>

<br>

<input type="text" id="username" name="username" required>

<br><br>

<label for="password">Password:</label>

<br>

<input type="password" id="password" name="password" required>

<br><br>

<button type="reset">Reset</button>

<button type="submit">Login</button>

</form>

</body>

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

</html>

get.php:

<?php

$u=$_GET["username"];

$p=$_GET["password"];

echo "The username is :".$u."<br>";

echo "The password is :".$p;

?>

OUTPUT:

ii)By using “POST” method:

<!DOCTYPE html>

<html lang="en">

<head>

<title>Simple Login Page</title>

</head>

<body>

<h1>Login Page</h1>

<form name="fn" method="POST" action="get.php">

<label for="username">Username:</label>

<br>

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

<input type="text" id="username" name="username" required>

<br><br>

<label for="password">Password:</label>

<br>

<input type="password" id="password" name="password" required>

<br><br>

<button type="reset">Reset</button>

<button type="submit">Login</button

</form>

</body>

</html>

post.php:

<?php

$u=$_POST["username"];

$p=$_POST["password"];

echo "The username is :".$u."<br>";

echo "The password is :".$p;

?>

OUTPUT:

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

ii)By using “REQUEST” method:

<!DOCTYPE html>

<html lang="en">

<head>

<title>Simple Login Page</title>

</head>

<body>

<h1>Login Page</h1>

<form name="fn" method="POST" action="get.php">

<label for="username">Username:</label>

<br>

<input type="text" id="username" name="username" required>

<br><br>

<label for="password">Password:</label>

<br>

<input type="password" id="password" name="password" required>

<br><br>

<button type="reset">Reset</button>

<button type="submit">Login</button>

</form>

</body>

</html>

Request.php:

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

<?php

$u=$_REQUEST["username"];

$p=$_REQUEST["password"];

echo "The username is :".$u."<br>";

echo "The password is :".$p;

?>

OUTPUT:

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

b) Develop a PHP program to demonstrate the importance of include() and require()


functions.

Urls.html:

<html>

<body>

<a href="https://erp.lbrce.ac.in/">LBRCE ERP</a>

<a href="https://openai.com/index/chatgpt/">CHATGPT</a>

<a href="https://www.flipkart.com/">FLIPKART</a>

</body>

</html>

Include.php:

<?php

include "urls.html";

echo "</br>";

require "urls.html";

echo "</br>";

include "urls.html";

?>

OUTPUT:

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

Include and require (without HTML File):

<?php

include "urlss.html";

echo "</br>";

echo "HI";

require "urlss.html";

echo "</br>";

include "urlss.html";

?>

OUTPUT:

Details.php:

<?php

$regno="F8";

$name="Kollipara Akhil";

$branch="Computer Science and Engineering";

$Dob="18-06-2004";

?>

Retrive Details.php:

<?php

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8


Module No:04 Date: 07-01-2025

include "details.php";

echo "Roll Number:".$regno;

echo "</br>";

echo "Full name:".$name;

echo "</br>";

echo "Branch:".$branch;

echo "</br>";

echo "Date of Birth:".$Dob;

?>

OUTPUT:

Laki Reddy Bali Reddy College of Engineering-Dept.of CSE Reg.No:22761A05F8

You might also like