0% found this document useful (0 votes)
8 views7 pages

Experiment 11 dbms[1]

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

Experiment 11 dbms[1]

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Experiment - 11

Objective: Design and implementation of Student Information System


Specification: To create a database with an interface for implementing student information
system for an educational organization.
a) Hardware & Software Design Requirements
S. No. Requirements Configuration

1 System 1

2 Operating System Windows 7 or higher / Linux

3 Front End C++/Java/Php etc.

4 Back End Oracle 11g/MySql


b) Steps for Achieving Objective
i. Create the database design with required tables (using SQL) as:
 Admin (admin_id, admin_name, admin_pass)
 Student Details (roll no, name, age, address, dob, email id, phno, course_enrolled,
section, group etc as required)
 Department (dept_id, dept_name, head_name etc as required)
(Apart from these additional tables/fields can be added as required)
ii. Create the system design with features for adding students by admin after login. Students
could view and update their details, department could enroll and view students as per the
database design created in step i.
iii. Basic project should contain required design forms with features to support step ii.

Implementation:-
1. Database Connection (db.php)
php
<?php
$servername = "localhost"; // Your server name
$username = "root"; // Your database username
$password = ""; // Your database password (leave empty if not set)
$dbname = "student_information_system"; // Your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>

2. Admin Login (admin_login.php)

php
<?php include 'db.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Login</title>
</head>
<body>
<h2>Admin Login</h2>
<form method="POST" action="">
<label for="admin_name">Username:</label>
<input type="text" name="admin_name" required><br>

<label for="admin_pass">Password:</label>
<input type="password" name="admin_pass" required><br>

<input type="submit" value="Login">


</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$admin_name = $_POST['admin_name'];
$admin_pass = $_POST['admin_pass'];

// Check credentials (you should hash passwords in a real application)


$sql = "SELECT * FROM Admin WHERE admin_name = ? AND admin_pass = ?";

$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $admin_name, $admin_pass);

$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
echo "Login successful!";
// Redirect to add student page or dashboard here
// header("Location: add_student.php");
exit();
} else {
echo "Invalid username or password.";
}
}
$stmt->close();
$conn->close();
?>
</body>
</html>
3. Add Student (add_student.php)
php
<?php include 'db.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Student</title>
</head>
<body>
<h2>Add New Student</h2>
<form method="POST" action="">
<label for="roll_no">Roll No:</label>
<input type="number" name="roll_no" required><br>

<label for="name">Name:</label>
<input type="text" name="name" required><br>

<label for="age">Age:</label>
<input type="number" name="age"><br>

<label for="address">Address:</label>
<input type="text" name="address"><br>

<label for="dob">Date of Birth:</label>


<input type="date" name="dob"><br>

<label for="email_id">Email ID:</label>


<input type="email" name="email_id"><br>

<label for="phno">Phone Number:</label>


<input type="text" name="phno"><br>

<label for="course_enrolled">Course Enrolled:</label>


<input type="text" name="course_enrolled"><br>

<label for="section">Section:</label>
<input type="text" name="section"><br>

<label for="group_name">Group:</label>
<input type="text" name="group_name"><br>

<input type="submit" value="Add Student">


</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {

// Retrieve form data and insert into database


$roll_no = $_POST['roll_no'];
$name = $_POST['name'];
$age = $_POST['age'];
$address = $_POST['address'];
$dob = $_POST['dob'];
$email_id = $_POST['email_id'];
$phno = $_POST['phno'];
$course_enrolled = $_POST['course_enrolled'];
$section = $_POST['section'];
$group_name = $_POST['group_name'];

// Insert into Student_Details table


$sql = "INSERT INTO Student_Details (roll_no, name, age, address, dob, email_id, phno,
course_enrolled, section, group_name)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

$stmt = $conn->prepare($sql);
$stmt->bind_param("isssssssss",
$roll_no,
$name,
$age,
$address,
$dob,
$email_id,
$phno,
$course_enrolled,
$section,
$group_name);

if ($stmt->execute()) {
echo "New student added successfully!";
} else {
echo "Error: " . $stmt->error;
}

// Close statement and connection


$stmt->close();
}
$conn->close();
?>
</body>
</html>
Output:-

You might also like