0% found this document useful (0 votes)
7 views10 pages

Task 4

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)
7 views10 pages

Task 4

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/ 10

Task-4: Develop an Add Student Profile Page which

accepts all student details including photo and display


them in order.
PROGRAMS:
Addstudent.php
<?php include('../header.php') ?>
<div class="header-section jumbotron">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center">
WELCOME TO ADMIN DASHBOARD
<span><a href="logout.php" class="btn btn-success" style="float:
right;">LOGOUT</a><span>
</h2>
</div>
</div>
</div>
</div>
<div class="admin-dashboard text-center">
<div class="container">
<div>
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron" >
<a href="addstudent.php" class="btn btn-info btn-lg">INSERT STUDENT
DETAIL</a><br><br>
<a href="updatestudent.php" class="btn btn-info btn-lg">UPDATE STUDENT
DETAIL</a><br><br>
<a href="deletestudent.php" class="btn btn-info btn-lg">DELETE STUDENT
DETAIL</a>
</div>
</div>
</div>
</div>
</div>
<?php include('../footer.php') ?>

Deleterecord.php
<?php
include('../dbcon.php');
$delete_id = $_GET['Delete'];
$profile_pic = $_GET['Picture'];
$sql = "delete from `student` where id = $delete_id";
$result = mysqli_query($conn,$sql);
if ($result) {
unlink("../databaseimg/".$profile_pic);
echo '<script>window.open("deletestudent.php?deleted=Record deleted
successfully","_self")</script>';
}
?>

Deletestudent.php
<?php require_once('../include/Session.php');?>
<?php require_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>
<?php include('../header.php') ?>
<?php include('admin.header.php') ?>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron ">
<div style="text-align: center;">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post" enctype="multipart/form-data" >
Choose Standard: <select name="standard" class="btn btn-info" style="margin-
right: 30px;">
<option>Select</option>
<option>1st</option>
<option>2nd</option>
<option>3rd</option>
<option>4th</option>
<option>5th</option>
</select>
<input type="submit" name="search" value="SEARCH" class="btn btn-
success">
</form>
</div>
</div>
</div>
<table class="table table-striped table-bordered table-responsive text-center">
<h2 class="text-center">Student's Information</h2>
<tr>
<th class="text-center">Roll No.</th>
<th class="text-center">Full Name</th>
<th class="text-center">City</th>
<th class="text-center">Parent Phone No.</th>
<th class="text-center">Profile Pic</th>
<th class="text-center">Delete</th>
</tr>
<?php
include('../dbcon.php');
if (isset($_POST['search'])) {
$standard = $_POST['standard'];
$sql = "SELECT * FROM `student` WHERE `standard` = '$standard'";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result)>0) {
while ($DataRows = mysqli_fetch_assoc($result)) {
$Id = $DataRows['id'];
$RollNo = $DataRows['rollno'];
$Name = $DataRows['name'];
$City = $DataRows['city'];
$Pcontact = $DataRows['pcontact'];
$ProfilePic = $DataRows['image'];
?>
<tr>
<td><?php echo $RollNo;?></td>
<td><?php echo $Name; ?></td>
<td><?php echo $City; ?></td>
<td><?php echo $Pcontact; ?></td>
<td><img src="../databaseimg/<?php echo $ProfilePic;?>" alt="img"></td>
<td><a href="deleterecord.php?Delete=<?php echo $Id; ?>&Picture=<?php
echo $ProfilePic;?>" class="btn btn-danger">Delete</a></td>
</tr>
<?php
}
} else {
echo "<tr><td colspan ='6' class='text-center'>No Record Found</td></tr>";
}
}
?>
</table>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2><?php echo @$_GET['deleted']; ?></h2>
</div>
</div>
</div>
<?php include('../footer.php') ?>

Admin.header.php
<div class="header-section jumbotron">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center">
<span><a href="admindash.php" class="btn btn-success" style="float:
left;">BACK TO DASHBOARD</a><span>
WELCOME TO ADMIN DASHBOARD
<span><a href="logout.php" class="btn btn-success" style="float:
right;">LOGOUT</a><span>
</h2>
</div>
</div>
</div>
</div>

Imageupload.php
<?php
$imgName = $_FILES['simg']['name'];
$imgTmpName =$_FILES['simg']['tmp_name'];
$imgSize = $_FILES['simg']['size'];
$imgError = $_FILES['simg']['error'];
$imgExt = explode('.', $imgName);
$actualFileExt = strtolower(end($imgExt));
$allowed = array('jpg','jpeg','png','pdf');
if (in_array($actualFileExt, $allowed)) {
if ($imgError === 0) {
if ($imgSize < 50000) {
$fileDestination = '../databaseimg/'.$imgName;
move_uploaded_file($imgTmpName, $fileDestination);
} else {
echo "file size is too big";
}
}else{
echo "error while uploading your file";
}
}else {
echo "you cannot upload files of this type";
}

Updaterecord.php
<?php require_once('../include/Session.php');?>
<?php require_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>
<?php
include('../dbcon.php');
$update_record= $_GET['Update'];
$sql = "select * from student where id = '$update_record'";
$result = mysqli_query($conn,$sql);
while ($data_row = mysqli_fetch_assoc($result)) {
$update_id = $data_row['id'];
$Roll = $data_row['rollno'];
$Name = $data_row['name'];
$City = $data_row['city'];
$Pcontact = $data_row['pcontact'];
$Standard = $data_row['standard'];
}
?>
<?php include('../header.php') ?>
<?php include('admin.header.php') ?>
<div class="container jumbotron">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2 class="text-center">UPDATE STUDENT DETAIL</h2>
<form action="UpdateRecord.php?update_id=<?php echo $update_id;?>"
method="post" enctype="multipart/form-data">
<div class="form-group">
Roll No.:<input type="text" class="form-control" name="roll" value="<?php
echo
$Roll;?>" >
</div>
<div class="form-group">
Full Name:<input type="text" class="form-control" name="fullname" value="<?
php echo
$Name;?>" placeholder="full name" required>
</div>
<div class="form-group">
City: <input type="text" class="form-control" name="city" value="<?php echo
$City;?>" required>
</div>
<div class="form-group">
Parent Phone No.:<input type="text" class="form-control" name="pphone"
value="<?php echo $Pcontact;?>" required>
</div>
<div class="form-group">
Standard:<input type="number" class="form-control" name="standard"
value="<?php echo $Standard;?>" required>
</div>
<button type="submit" name="submit" class="btn btn-success btn-
lg">UPDATE</button>
</form>
</div>
</div>
</div>
<?php include('../footer.php') ?>
<?php
//This php code block is for editing the data that we got after clicking on
update button
if (isset($_POST['submit'])) {
if (!empty($_POST['roll']) && !empty($_POST['fullname'])) {
include ('../dbcon.php');
$id = $_GET['update_id'];
$roll=$_POST['roll'];
$name=$_POST['fullname'];
$city=$_POST['city'];
$pphone=$_POST['pphone'];
$standard=$_POST['standard'];
$sql = "UPDATE student SET rollno = '$roll', name = '$name', city='$city',
pcontact = '$pphone', standard = '$standard' WHERE id = '$id'";
$Execute = mysqli_query($conn,$sql);
if ($Execute) {
$_SESSION['SuccessMessage'] = " Data Updated Successfully";
Redirect_to("updatestudent.php");
}
}
}
?>

Logout.php
<?php
session_start();
session_destroy();
header('location:../login.php');
?>

You might also like