Practical-18: Write a program to create a login form.
On
submitting the form, the user.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == "admin" && $password == "12345") {
header("Location: [Link]");
exit();
} else {
echo "<p style='color:red;'>Invalid username or password!</p>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Form</title>
</head>
<body style="text-align:center;">
<h2>Login Page</h2>
<form method="post" action="">
Username: <input type="text" name="username" required><br><br>
Password: <input type="password" name="password"
required><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Output:
Practical-19: Design front page of a college or department
using graphics method.
<?php
$collegeName = “PIMT”;
$fullName = “Punjab Institute of Management and Technology”;
$year = date(“Y”);
?>
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-
scale=1.0″>
<title><?php echo $collegeName; ?> – Front Page</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: #f0f0f5;
header {
background: linear-gradient(90deg, #00509e, #00274d);
color: white;
padding: 20px;
text-align: center;
header h1 {
margin: 0;
font-size: 3em;
header p {
margin: 5px 0 0;
font-size: 1.2em;
nav {
display: flex;
justify-content: space-around;
background: #003566;
padding: 10px 0;
nav a {
color: white;
text-decoration: none;
font-size: 1.2em;
nav a:hover {
text-decoration: underline;
.banner {
background: url(‘college_banner.jpg’) no-repeat center center/cover;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
color: white;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
.banner h2 {
font-size: 3em;
.cards {
display: flex;
justify-content: center;
gap: 20px;
padding: 20px;
}
.card {
background: white;
width: 30%;
padding: 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 5px;
text-align: center;
.card h3 {
margin-top: 0;
footer {
background: #003566;
color: white;
text-align: center;
padding: 10px;
</style>
</head>
<body>
<header>
<h1><?php echo $collegeName; ?></h1>
<p><?php echo $fullName; ?></p>
</header>
<nav>
<a href=”#about”>About Us</a>
<a href=”#programs”>Programs</a>
<a href=”#admissions”>Admissions</a>
<a href=”#contact”>Contact Us</a>
</nav>
<div class=”banner”>
<h2>Welcome to <?php echo $collegeName; ?></h2>
</div>
<div class=”cards”>
<div class=”card”>
<h3>Academic Excellence</h3>
<p>High standards of education and innovation.</p>
</div>
<div class=”card”>
<h3>Modern Facilities</h3>
<p>World-class infrastructure for student success.</p>
</div>
<div class=”card”>
<h3>Dynamic Campus Life</h3>
<p>Engaging activities for holistic development.</p>
</div>
</div>
<footer>
<p>© <?php echo $year; ?> <?php echo $collegeName; ?>. All
Rights Reserved.</p>
</footer>
</body>
</html>
Output:
Displays a webpage with title, image, department list, and contact info.
3. File Upload and Download
This program allows uploading and downloading files using PHP.
Code for [Link]:
<?php
if (isset($_POST['submit'])) {
$file = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
if (!file_exists("uploads")) {
mkdir("uploads", 0777, true);
}
move_uploaded_file($temp, "uploads/" . $file);
echo "File uploaded successfully! <a href='uploads/$file'>Download File</a>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body style="text-align:center;">
<h2>Upload a File</h2>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" required>
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
Output:
Upload a file -> Displays 'File uploaded successfully!' with a download link.