File: //home/jibhires/d1.brightsolutionsindia.com/register.php
<?php
// Database configuration
$servername = "localhost";
$username = "jibhires_syrma";
$password = "0*YzVc5}%l){";
$dbname = "employee_attendance";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$section = $_POST["section"];
$level = $_POST["level"];
// Handle photo upload
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["photo"]["name"]);
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
// Validate image
$check = getimagesize($_FILES["photo"]["tmp_name"]);
if($check !== false && move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file)) {
// Insert into database
$sql = "INSERT INTO employees (name, section, level, photo_path)
VALUES ('$name', '$section', $level, '$target_file')";
if ($conn->query($sql) {
echo "<p>Employee registered successfully!</p>";
} else {
echo "<p>Error: " . $conn->error . "</p>";
}
} else {
echo "<p>Invalid image file.</p>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Employee Registration</title>
<style>
.form-group { margin-bottom: 15px; }
label { display: inline-block; width: 120px; }
</style>
</head>
<body>
<h1>Employee Registration</h1>
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label>Name:</label>
<input type="text" name="name" required>
</div>
<div class="form-group">
<label>Section:</label>
<select name="section" required>
<option value="PCBA">PCBA</option>
<option value="PREFAB">PREFAB</option>
<option value="SUB ASSEMBLY">SUB ASSEMBLY</option>
<option value="ASSEMBLY 1">ASSEMBLY 1</option>
<option value="ASSEMBLY 2">ASSEMBLY 2</option>
<option value="ASSEMBLY 3">ASSEMBLY 3</option>
<option value="ASSEMBLY 4">ASSEMBLY 4</option>
<option value="ASSEMBLY 5">ASSEMBLY 5</option>
<option value="PACKING">PACKING</option>
</select>
</div>
<div class="form-group">
<label>Level:</label>
<input type="number" name="level" min="1" required>
</div>
<div class="form-group">
<label>Photo:</label>
<input type="file" name="photo" accept="image/*" required>
</div>
<button type="submit">Register</button>
</form>
</body>
</html>