Mark CRUD

1.

<!DOCTYPE html>
<html>
<head>
	<title>Input Student Marks</title>
</head>
<body>
	<h1>Input Student Marks</h1>
	<form method="post" action="save_marks.php">
		<label for="student_id">Student ID:</label>
		<input type="text" id="student_id" name="student_id" required>
		<br><br>
		<label for="subject_id">Subject ID:</label>
		<input type="text" id="subject_id" name="subject_id" required>
		<br><br>
		<label for="type">Type:</label>
		<select id="type" name="type">
			<option value="compulsory">Compulsory</option>
			<option value="optional">Optional</option>
		</select>
		<br><br>
		<label for="marks_obtained">Marks Obtained:</label>
		<input type="text" id="marks_obtained" name="marks_obtained" required>
		<br><br>
		<label for="total_marks">Total Marks:</label>
		<input type="text" id="total_marks" name="total_marks" required>
		<br><br>
		<input type="submit" value="Save Marks">
	</form>
</body>
</html>

2.

<?php
// Include the database connection file
require_once 'db_connect.php';

// Get the form data
$student_id = $_POST['student_id'];
$subject_id = $_POST['subject_id'];
$type = $_POST['type'];
$marks_obtained = $_POST['marks_obtained'];
$total_marks = $_POST['total_marks'];

// Prepare the SQL statement
$sql = "INSERT INTO results (student_id, subject_id, type, marks_obtained, total_marks) VALUES (?, ?, ?, ?, ?)";

// Bind the parameters and execute the statement
$stmt = $conn->prepare($sql);
$stmt->bind_param("iisdd", $student_id, $subject_id, $type, $marks_obtained, $total_marks);
$stmt->execute();

// Redirect back to the form
header("Location: input_mark_form.php");
exit;
?>

Last updated