<?
php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Database connection
$servername = "[Link]"; // Replace with your host name
$username = "if0_37991887"; // Replace with your MySQL user name
$password = "wSzeX0SzZ47A"; // Replace with your MySQL password
$dbname = "if0_37991887_epiz_12345678_try";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Form processing logic
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit_form'])) {
$faculty_name = $_POST['faculty_name'];
$degree = $_POST['degree'];
$designation = $_POST['designation'];
$from_date = $_POST['from_date'];
$to_date = $_POST['to_date'];
$acted_as = $_POST['acted_as'];
// Insert data into the database
$sql = "INSERT INTO faculty_form (faculty_name, degree, designation, from_date,
to_date, acted_as)
VALUES ('$faculty_name', '$degree', '$designation', '$from_date',
'$to_date', '$acted_as')";
if ($conn->query($sql) === TRUE) {
echo "<h2>Form submitted successfully!</h2>";
// Certificate preview
echo "
<div style='border:1px solid #ccc; padding:20px; margin-top:20px;'>
<h3>Certificate Preview:</h3>
<p><strong>BVC Engineering College</strong></p>
<p><strong>Date:</strong> " . date('d-m-Y') . "</p>
<p><strong>Faculty Name:</strong> $faculty_name</p>
<p><strong>Acted As:</strong> $acted_as</p>
<p><strong>Duration:</strong> From $from_date to $to_date</p>
<form method='POST'>
<input type='hidden' name='faculty_name' value='$faculty_name'>
<input type='hidden' name='from_date' value='$from_date'>
<input type='hidden' name='to_date' value='$to_date'>
<input type='hidden' name='acted_as' value='$acted_as'>
<button type='submit' name='download_certificate'>Download
Certificate</button>
</form>
</div>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// Download certificate logic
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['download_certificate']))
{
header("Content-type: application/[Link]-word");
header("Content-Disposition: attachment;Filename=[Link]");
$faculty_name = $_POST['faculty_name'];
$from_date = $_POST['from_date'];
$to_date = $_POST['to_date'];
$acted_as = $_POST['acted_as'];
echo "
<html>
<head>
<meta charset='UTF-8'>
<style>
body { font-family: 'Times New Roman', serif; font-size: 14px; }
.header { margin-bottom: 30px; }
.title { text-align: center; font-size: 16px; font-weight: bold; }
.content { text-align: justify; line-height: 1.8; }
</style>
</head>
<body>
<div class='header'>
<p><strong>BVC Engineering College</strong></p>
<p>Date: " . date('d-m-Y') . "</p>
</div>
<div class='title'>Certificate</div>
<div class='content'>
<p>This is to certify that <strong>$faculty_name</strong> has acted as
<strong>$acted_as</strong> from <strong>$from_date</strong> to
<strong>$to_date</strong>.</p>
</div>
</body>
</html>";
exit;
}
$conn->close();
?>