Shanifa

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Name: Haris Altaf Malik 19-arid-5326

File: conn.php

<?php
error_reporting(0);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "SCHOOLSYSTEM";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

?>

File: UserInsertion.php

<?php

include("conn.php");

$sql = "INSERT INTO Student (ID, StudentName, StudentDept,UserEmail)


VALUES ('".$_POST["txtStudentName"]."', '".$_POST["txtStudentEmail"]."', '".
$_POST["txtStudenDept"])";

if ($conn->query($sql) === TRUE) {


    echo "New Record of Student <b>".$_POST["txtStudentName"]."</b>
    has been added successfully in the Database..";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

?>

<html>
<body>
<br/>
<a href="StudentRegistraiton.HTML"> <b> Register New Student</b></a>
</body>
</html>
retrive:

<?php

include("conn.php");
$sql = "SELECT ID, StudentName, Studentpswd, StudentCellNo, StudentEmail, FROM
student";
$result= $conn->query($sql);
?>

Deletion:

<?php
include 'conn.php';
$sql = "DELETE FROM Student WHERE ID=11";
if ($conn->query($sql)==TRUE)
{
    echo "record deleted successfully";
}else{
        echo "Error deleting record:". $conn->error;
   
}
?>

Update:

<?php
include 'conn.php';
$sql = "UPDATE teacher SET email='Ali234@gmail.com' WHERE ID=20";
if ($conn->query($sql)==TRUE)
{
    echo "record updated successfully";
}else
{
        echo "Error updating record:". $conn->error;
   
}
?>

You might also like