You will be creating a full-stack website that uses the student information from a database as input and generates his/her result in PDF format as output which can then be downloaded and shared.
You will be creating a full-stack website that uses the student information from a database as input and generates his/her result in PDF format as output which can then be downloaded and shared.
In our day-to-day life, we come across various examination results such as school exam results, competitive exam results, college semester exam results, etc. How efficiently it produces someone's result by just filling in student details! But, have you ever thought of creating one? The ones who did basically went through the hectic job of perfecting their database and then using the knowledge of front-end and back-end to do so.
Developers are known for doing stuff automatically and efficiently. Thus we can have an easier take on it, by creating a system that accepts the student details as input and generates the desired result as output.
You will be creating a full-stack website that uses the student information from a database as input and generates his/her result in PDF format as output which can then be downloaded and shared.
In our day-to-day life, we come across various examination results such as school exam results, competitive exam results, college semester exam results, etc. How efficiently it produces someone's result by just filling in student details! But, have you ever thought of creating one? The ones who did basically went through the hectic job of perfecting their database and then using the knowledge of front-end and back-end to do so.
Developers are known for doing stuff automatically and efficiently. Thus we can have an easier take on it, by creating a system that accepts the student details as input and generates the desired result as output.
Our project is going to be a full stack application. A full stack application primarily comprises of 3 things - front-end, back-end and database.
So, this project is also divided into 3 parts:
We start by settings things up for the front-end, then for database and then move towards to the back-end part.
htdocs
folder of XAMPP and create a new folder by your preferred name for this project. Mine is SRMS
.apache
and mysql
in new tabs.mysql tab
. Go ahead and create a database with the same name as project folder. For my case it will be SRMS
.index.php
file, you can change it in settings.dashboard
in the URL change it to your project folder name i.e. SRMS
then put a forward slash and type your file name that you want to open. Ex. SRMS/homepage.html
.The main objective of this milestone is to make sure that you understand the basic overflow of the project. Also, you should have a code editor and apache distribution in place. With this you should be able to access the MySQL, phpmyadmin home page and your project files.
Let's start ourselves from the result section!!
What exactly we want from our system? Yes, you are thinking it right. We want from our system that it should take student details as input such as roll no
, class
, dob
(for hiding it from other students, if required) and produce his/her result as output. Make a .php
file with some convenient name and make a form which takes roll no
and class
as input. On submit, it should perform required SQL query(s) to obtain the result as output.
But wait! From which table are we going to fetch the required data? Did we create any table in the srms
database? Yes, you are right, we don't have any table yet. Go ahead and create a table called students
. But what should be the attributes in the table? The simplest table should have at least these following attributes -
StudentId
=> unique key for each studentStudentName
=> student nameRollId
=> roll numberClassName
=> class nameClassSection
=> section of class (if needed)SubjectName
=> all subjects name in separate tupleMarks
=> marks of that particular subjectApart from that you can add attributes if you want such as gender, mail, contact number, etc. But this should be there for proper data storing and fetching. Shouldn't it?
students
table on your own for now.srms
to your PHP page.students
table where roll no
and class
matches with your database entries.You should be able to make a database, table and attributes with some data into it. You should also be able to get student data as input, parse it, perform search queries and output it to the user.
Let's analyze our previous database from various DBMS perspectives.
The answer to all the questions is NO, why? Think about it.
Let's suppose if some student data is changed like address, contact number, etc. Then, we have to reflect that change at all the entries in the database because there are many entries for a single unique student depends on number of subjects.
Also, it is not looking great if we have to scale it for various classes, schools, etc. Because at the end data will become more and more redundant. Also, we can't perform other high level operations on this current database due to its not so good looking structure.
You should be able to justify why this database will not be a good fit in terms of various purposes that are mentioned above. You should be able to understand what normalization is and why there is need to normalize.
Let's split our original table students
into various usable and manageable tables. The tables are split in a manner such that data will remain consistent.
students
table after updating the data according to the new tables.status
attribute in each table which can be a boolean variable storing 0/1 depending upon that particular entry is currently in work or not.You should be able to make various tables for this database and its corresponding attributes.
Now, as we have our new database structure, we definitely have to rewrite the SQL queries for student result fetching.
Start from what your user will type at the front-end. We can safely assume that your user will know at least his/her Roll Id, Class Name and Section. But our user doesn't know that how the class name and section is stored in the database. Also, we as developers don't know that how users will type his/her class name and section because there are many possibilities.
So, to make it clear for both the user and you, we should give them a drop-down menu of all the classes in our database. From which table of our database we will do it? Yes, you are right from tblclasses
table. User will see his/her class name along with section and in return we will store the class id.
Here's the code for your reference.
<select name="class" class="form-control" id="default" required="required">
<option value="">Select Class</option>
<?php $sql = "SELECT * from tblclasses";
$query = $dbh->prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
if($query->rowCount() > 0) {
foreach($results as $result) { ?>
<option value="<?php echo htmlentities($result->id); ?>"><?php echo htmlentities($result->ClassName); ?> Section-<?php echo htmlentities($result->Section); ?>
</option>
<?php }} ?>
</select>
Store the roll id and class id in some variables on the redirected page after user click submit.
$rollid=$_POST['rollid'];
$classid=$_POST['class'];
$_SESSION['rollid']=$rollid;
$_SESSION['classid']=$classid;
Now, coming to the query part where we bind our above parameters and fetch student result. Result should at least contains his/her subject name (not subject id because user don't know about subject id at all), corresponding marks.
Here's the query for the same.
"select t.StudentName, t.RollId, t.ClassId, t.marks, SubjectId, tblsubjects.SubjectName from
(select sts.StudentName, sts.RollId, sts.ClassId, tr.marks, SubjectId from
tblstudents as sts join tblresult as tr on tr.StudentId=sts.StudentId) as t
join tblsubjects on tblsubjects.id=t.SubjectId where (t.RollId=:rollid and t.ClassId=:classid)"
You should be able to fetch and output student result accurately by taking input as per your willingness.
As said earlier this project is divided into 3 parts:
We settled up things for the front-end and database, it's time to move towards the back-end part.
But is there any need to develop a back-end part separately? Why this is required?
Till now we have been doing our back-end part with the database. But this is not looking convenient for adding, deleting and modifying data. That's why there is a need to make a separate back-end portal where we can add/update student details like class, subject, subject combination, result and other details through a proper UI.
The main motive of this milestone is to understand the concept behind making an admin portal. You should be able to design basic outline of the admin portal.
Let's try to build each module (renamed option to module).
Here, I will explain 2 functionalities - add and update classes. Rest all are similar in nature just the SQL query changes.
Add Class
Make a form which takes all the input corresponding to each attribute in tblclasses
table.
On submitting the form it should perform a MySQL insert query into the tblclasses
of same database.
Your back-end code should resemble below code -
$classname=$_POST['classname'];
$section=$_POST['section'];
$sql="INSERT INTO tblclasses(ClassName, Section) VALUES(:classname, :section)";
$query = $dbh->prepare($sql);
$query->bindParam(':classname', $classname, PDO::PARAM_STR);
$query->bindParam(':section', $section, PDO::PARAM_STR);
$query->execute();
$lastInsertId = $dbh->lastInsertId();
if($lastInsertId) {
$msg="Class Created successfully";
} else {
$error="Something went wrong. Please try again";
}
Update Class
Make a table which shows all the classes details such as serial number, class name, class section, etc. depending on your table structure.
Make an extra column for each row for editing that entry in the database, attach the class id with that value.
Print the existing details in form format for that class id to user using MySQL select command which user can change.
After submitting form, the back-end of that page should perform MySQL update query as follows -
$classname=$_POST['classname'];
$section=$_POST['section'];
$cid=intval($_GET['classid']);
$sql="update tblclasses set ClassName=:classname, Section=:section where id=:cid";
$query = $dbh->prepare($sql);
$query->bindParam(':classname', $classname, PDO::PARAM_STR);
$query->bindParam(':section', $section, PDO::PARAM_STR);
$query->bindParam(':cid',$cid, PDO::PARAM_STR);
$query->execute();
$msg="Data has been updated successfully";
phpmyadmin
database server.enable
/disable
button in admin portal for taking DOB also as input during result checking by user.You should able to design, code and test each module using your admin portal and phpmyadmin
database server.
Now, the need arises to secure this admin section. Why? Because otherwise students will change theirs and others results and details which in turn becomes a very serious issue.
There are two ways to secure this admin section - first is to separate this portal completely with new location and project while the second is to make it password protected. First is not actually a full proof solution. Why? Because if anyone gets to know about this portal and its location then eventually the same problem still persists. So, we will go with the second approach.
Make a new table into database with attributes - UserName
and Password
.
Fill these values depending on the administrative team.
Make a form which accepts user name and password as an input and in turns verifies from this table data.
If the entries filled are correct then store these values in the session for future reference and land him to the actual admin section.
$uname=$_POST['username'];
$password=md5($_POST['password']);
$sql ="SELECT UserName, Password FROM admin WHERE UserName=:uname and Password=:password";
$query= $dbh -> prepare($sql);
$query-> bindParam(':uname', $uname, PDO::PARAM_STR);
$query-> bindParam(':password', $password, PDO::PARAM_STR);
$query-> execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
if($query->rowCount() > 0) {
$_SESSION['alogin']=$_POST['username'];
echo "<script type='text/javascript'> document.location = 'dashboard.php'; </script>";
} else {
echo "<script>alert('Invalid Details');</script>";
}
The main motive of this milestone is to make admin section secure. You should be able to authenticate the person before sending him to the admin section.
Now, we are at the end stage of this project. We will try to put all things together and test it. Additionally you will learn how to generate PDF with required content so that one can download and share it wherever he/she wants.
The main motive of this milestone is to make every cluster club together and test it's functionalities.