To create an attractive HTML and CSS page for a Diwali voucher with a company logo, images, and a GIF, follow these steps. The setup will include a form for employees to enter their Employee IDs, and it will save the data using PHP on an IIS server.
Step 1: Prepare Your Assets
Ensure you have the following assets ready:
- Company Logo:
company-logo.png
- Diwali Images or Graphics: Example -
diwali-banner.png
- GIF File: Example -
diwali-gif.gif
- Directory Path: Make sure these assets are stored in the directory that IIS serves, typically
C:\inetpub\wwwroot.
Step 2: Create the HTML and CSS Page
Create an index.html file with the following content to design your web page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Diwali Voucher Redemption</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #fff3e0;
margin: 0;
padding: 20px;
text-align: center;
}
header {
background-color: #f57c00;
padding: 10px;
color: white;
}
img.logo {
max-width: 100px;
}
main {
background: white;
margin-top: 20px;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}
img.banner, img.gif {
width: 100%;
max-width: 600px;
border-radius: 10px;
margin: 10px 0;
}
input[type="text"] {
width: calc(100% - 22px);
padding: 10px;
margin: 15px 0;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #f57c00;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
footer {
color: #555;
padding-top: 20px;
}
</style>
</head>
<body>
<header>
<img src="company-logo.png" alt="Company Logo" class="logo">
<h1>Happy Diwali!</h1>
</header>
<main>
<img src="diwali-banner.png" alt="Diwali Banner" class="banner">
<div class="voucher">
<form action="saveData.php" method="post">
<h2>Redeem Your Diwali Voucher</h2>
<input type="text" id="employeeId" name="employeeId" placeholder="Enter Your Employee ID" required>
<br>
<input type="submit" value="Submit">
</form>
</div>
<img src="diwali-gif.gif" alt="Diwali Animated GIF" class="gif">
</main>
<footer>
<p>© 2023 Company Name | Enjoy the Festival of Lights!</p>
</footer>
</body>
</html>
Step 3: Create the PHP Script to Save Data
Create a PHP script named saveData.php to handle form submissions and save data:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Capture the Employee ID from POST data
$employeeId = htmlspecialchars($_POST['employeeId']);
// Define the file path for storing submitted data
$filePath = __DIR__ . '/employee_voucher_data.txt';
// Get user's IP address
$ipAddress = $_SERVER['REMOTE_ADDR'];
// Prepare data to be written
$dataToWrite = "Employee ID: " . $employeeId . " | IP: " . $ipAddress . "\n";
// Append the data to the file
file_put_contents($filePath, $dataToWrite, FILE_APPEND);
// Redirect to a thank you page or indicate successful submission
header('Location: thankyou.html');
exit();
}
?>
Step 4: Create a Thank You Page
Set up thankyou.html to confirm submission completion:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thank You!</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #fff3e0;
margin: 0;
}
.message {
text-align: center;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
}
</style>
</head>
<body>
<div class="message">
<h1>Thank You!</h1>
<p>Your entry has been successfully submitted. Enjoy your Diwali!</p>
</div>
</body>
</html>
Step 5: Deploy to IIS
-
Copy Files to IIS Directory:
- Place
index.html, saveData.php, thankyou.html, and all images under C:\inetpub\wwwroot.
-
Configure IIS:
- Open IIS Manager and ensure PHP is configured correctly, perhaps using FastCGI if not done.
- Double-check file permissions, allowing write access to
employee_voucher_data.txt.
-
Test Your Application:
- Access
http://your-server-ip/index.html in a browser.
- Test the form to see it captures Employee IDs and redirects as desired.
Important Considerations
- Security: Employ proper input validation to mitigate security risks.
- Aesthetic Design: You can adjust colors, fonts, and other styles to better match your branding and festive theme.
- Data Management: Consider transitioning to a database for robust data handling if the application's scope increases.
This setup not only showcases how to build festive and functional web components but also covers the deployment basics on an IIS server using PHP for backend functionality.