Fsd-Assignment:: Student App
Fsd-Assignment:: Student App
Assignment:
2211CS020420
1. Student App:
Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="index-container">
<div class="button-container">
</div>
</div>
</body>
</html>
Insert.php:
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student_management";
// Create connection
// Check connection
if ($conn->connect_error) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$student_name = $_POST['student_name'];
$roll_number = $_POST['roll_number'];
$section = $_POST['section'];
$dob = $_POST['dob'];
$address = $_POST['address'];
$gender = $_POST['gender'];
$resume = $_FILES['resume']['name'];
$target_dir = "../uploads/";
allowed."; exit;
if (move_uploaded_file($_FILES["resume"]["tmp_name"], $target_file)) {
$sql = "INSERT INTO students (student_name, roll_number, section, dob, address, gender,
area_of_interest, resume_path)
} else {
} else {
$conn->close();
?>
View.php:
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student_management";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
$sql = "SELECT * FROM students WHERE student_name LIKE '%$search%' OR roll_number LIKE '%
$search%'";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Students</title>
</head>
<body>
<h1>Student Records</h1>
</form>
<table>
<tr>
<th>Name</th>
<th>Roll Number</th>
<th>Section</th>
<th>DOB</th>
<th>Address</th>
<th>Gender</th>
<th>Interests</th>
<th>Resume</th>
</tr>
<?php
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc())
{ echo "<tr>
<td>{$row['student_name']}</td>
<td>{$row['roll_number']}</td>
<td>{$row['section']}</td>
<td>{$row['dob']}</td>
<td>{$row['address']}</td>
<td>{$row['gender']}</td>
<td>{$row['area_of_interest']}</td>
<td><a href='{$row['resume_path']}'>Download</a></td>
</tr>";
} else {
$conn->close();
?>
</table>
</body>
</html>
Output:
2. Employee:
Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Employee Form</title>
</head>
<body>
<form id="employeeForm">
<label for="country">Country:</label>
<option value="USA">USA</option>
<option value="India">India</option>
</select>
<label for="state">State:</label>
</select>
<label for="city">City:</label>
</select>
<!-- Other form fields like Employee Name, ID, etc. go here -->
</form>
<script>
const stateCityMapping =
{ "USA": {
},
"India": {
};
function populateState() {
if (stateCityMapping[country]) {
option.value = st;
option.textContent = st;
state.appendChild(option);
function populateCity() {
cities.forEach(function (cityName) {
option.value = cityName;
option.textContent = cityName;
city.appendChild(option);
});
}
</script>
</body>
</html>
Process.php:
<?php
// Connect to Database
$servername = "localhost";
if ($conn->connect_error) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['employeeName'];
$id = $_POST['employeeId'];
$doj = $_POST['doj'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$photoName = $_FILES['employeePhoto']['name'];
$photoSize = $_FILES['employeePhoto']['size'];
$photoTmpName = $_FILES['employeePhoto']['tmp_name'];
// Save File
$uploadDir = "uploads/";
move_uploaded_file($photoTmpName, $uploadFilePath);
$sql = "INSERT INTO employees (name, employee_id, date_of_joining, gender, photo, country,
state, city)
} else {
$conn->close();
?>
Output: