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

Module4 (1)

The document provides PHP code examples demonstrating form handling using GET, POST, and REQUEST methods, along with the use of include() and require() functions. It includes HTML forms for user login and PHP scripts to retrieve and display submitted data. Additionally, it showcases how to include external HTML and PHP files to manage content effectively.

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)
8 views

Module4 (1)

The document provides PHP code examples demonstrating form handling using GET, POST, and REQUEST methods, along with the use of include() and require() functions. It includes HTML forms for user login and PHP scripts to retrieve and display submitted data. Additionally, it showcases how to include external HTML and PHP files to manage content effectively.

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:22761A05I1


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:22761A05I1


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:22761A05I1


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:22761A05I1


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:22761A05I1


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:22761A05I1


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="I1";

$name="Gunasekhar Parisa";

$branch="Computer Science and Engineering";

$Dob="13-01-2004";

?>

Retrive Details.php:

<?php

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


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:22761A05I1

You might also like