Page 306 - Computer Software Application TP - Volume 1
P. 306
COMPUTER SOFTWARE APPLICATION - CITS
EXERCISE 57 : Demonstrate redirecting the user, File
upload and scripts
Objectives
At the end of this exercise you shall be able to
• redireet user to one page to other using PHP.
Requirements
Tools/Materials
• Computer/Laptop with latest configuration • PHP
• Operating system: windows 10 or 11 • Text editor
• Apache web server • Web browser
Procedure
TASK 1: Redirecting a user
I Using header() function
1 Open the text editor
2 Write the following codes
<html >
<head>
<title >Using header() function </title>
</head>
<body>
<?php
// Redirect to another page after 5 seconds
header(“Location:destination-page.php”);
exit; // Make sure to exit after sending the header
?>
</body>
</html>
3 Save the program in C:\Apache24\htdocs in a folder with .php extension
4 Run the Apache services from windows services
5 Open the browser and type the following address
http://localhost/foldername/
6 Click the php file to run and verify the output
291