MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/localapp/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/localapp/add_emp.php
<?php

include("includes/config.php");

if(isset($_POST['add_emp'])){
    $type = $_POST['type'];
    $username = $_POST['username'];
    $password = $_POST['password'];
    $phone = $_POST['phone'];

    // Sanitize input data (for example, you can use mysqli_real_escape_string)
    $type = mysqli_real_escape_string($conn, $type);
    $username = mysqli_real_escape_string($conn, $username);
    $password = mysqli_real_escape_string($conn, $password);
    $phone = mysqli_real_escape_string($conn, $phone);


    // Construct the SQL query with sanitized input data
    $query = "INSERT INTO `admin` (`type`, `username`, `password`,`phone`) VALUES ('$type', '$username', '$password', '$phone')";
    $query_run = mysqli_query($conn, $query);

    if($query_run){

        $_SESSION['status'] = "Employee Added Successfully";
        header('Location: view-emp.php');
        exit;
    } else {
        $_SESSION['status'] = " Not Added ";
        header('Location: emp.php');
        exit;
    }
}



if(isset($_POST['update_emp'])){
    $id = $_POST['id'];
    $type = $_POST['type'];
    $username = $_POST['username'];
    $password = $_POST['password'];

    $type = mysqli_real_escape_string($conn, $type);
    $username = mysqli_real_escape_string($conn, $username);
    $password = mysqli_real_escape_string($conn, $password);

    // Update the department information in the database
    $query = "UPDATE admin SET type='$type', username='$username', password='$password' WHERE id ='$id'";

    $query_run = mysqli_query($conn, $query);

    if($query_run){
        $_SESSION['status'] = "Employee Updated Successfully";
        header('Location: view-emp.php');
    } else {
        $_SESSION['status'] = "Employee Not Updated ";
        header('Location: view-emp.php');
    }
}


// delete

if(isset($_POST['delete_emp'])){
    $id = $_POST['delete_id'];

    $query = "DELETE FROM admin WHERE id = '$id'";
    $query_run = mysqli_query($conn, $query);

    if($query_run){
        $_SESSION['status'] = "Deleted Successfully";
        header('Location: view-emp.php');
    } else {
        $_SESSION['status'] = "Not Deleted Successfully";
        header('Location: view-emp.php');
    }
}
?>

MMCT - 2023