Untitled

Anonymous
plain_text
03/23/2026 3:31 AM
13.2 KB
13
Indexable
<?php
// connect
$con = mysqli_connect("localhost", "root", "root", "ip_languido_database");

if (isset($_POST["btndelete"])) {  
    $id = (int)$_POST["checkbox1"]; 
    $command = "DELETE FROM tbl_employees WHERE employee_id=$id";
    mysqli_query($con, $command);
    echo "<script>alert('The Record has been deleted'); window.location='employee_main.php'</script>";
}



// ADD
if (isset($_POST["btnadd"])) {
  
    echo "<script>window.location='add_record.php'</script>";
     

    exit();
}


// EDIT
if (isset($_POST["btnedit"])) {
    if (!empty($_POST["checkbox1"])) {
        $email = $_POST["checkbox1"]; 
        echo "<script>window.location='edit_record.php?email=$email';</script>";
        exit();
    } else {
        echo "<script>alert('Please select a record to edit'); window.location='main.php';</script>";
        exit();
    }
}

?>






<html>
<head>
    <title>main.php</title>
    <style>
                    body {
                display: flex;
                justify-content: center;
                align-items: center;
                min-height: 100vh;
                background: #e6f2ff; /* light blue background */
                font-family: Arial, sans-serif;
            }

            form {
                text-align: center;
                background: #ffffff;
                padding: 20px 40px;
                border-radius: 10px;
                box-shadow: 0 4px 10px rgba(0,0,0,0.1);
            }

            table {
                margin: 20px auto;
                border: solid #004080 2px; /* dark blue border */
                border-collapse: collapse;
                width: 80%;
            }

            tr, td {
                border: solid #004080 1px;
                padding: 10px;
                text-align: center;
            }

        

            

        
    </style>
</head>
<body>
    <form method="post" action="main.php">

<?php


if (isset($_POST["btnsearch"]) ) {
    $search = mysqli_real_escape_string($con, $_POST["txtsearch"]);
    $command = "SELECT * FROM tbl_registration WHERE last_name = '$search'";
} else {
    $command = "SELECT * FROM tbl_registration";
}

$result = mysqli_query($con, $command);
if (mysqli_num_rows($result) == 0) {
    echo "<script>alert('NO RECORD FOUND');</script>";
}

echo "<table>";
echo "<tr style='background-color: pink'>";
echo "<td></td>";
echo "<td>FIRST NAME</td>";
echo "<td>LAST NAME</td>";
echo "<td>USER NAME</td>";
echo "<td>EMAIL ADDRESS</td>";
echo "<td>PASSWORD</td>";
echo "</tr>";

while ($record = mysqli_fetch_row($result)) {
    echo "<tr>";
    echo "<td><input type='checkbox' name='checkbox1' value='". $record[3]."'></td>";
    echo "<td>" . $record[0] . "</td>";
    echo "<td>" . $record[1] . "</td>";
    echo "<td>" . $record[2] . "</td>";
    echo "<td>" . $record[3] . "</td>";
    echo "<td>" . $record[4] . "</td>";
    echo "</tr>";
}
echo "</table>";
?>
  <input type="submit" name="btnedit" value="EDIT">
    <input type="submit" name="btnadd" value="ADD A NEW RECORD">
    <input type="submit" name="btndelete" value="DELETE">
     <br>
    <br>
    Enter your Last Name:
    <input type="text" name="txtsearch">
    
    <input type="submit" name="btnsearch" value="SEARCH">
    <input type="submit" name="btnrefresh" value="REFRESH">
</form>
</body>
</html>










<?php
// Database connection
$con = mysqli_connect("localhost", "root", "root", "ip_languido_database");

// SAVE
if (isset($_POST["btnsave"])) {
    $command = "INSERT INTO tbl_registration VALUES (";
    $command .= "'" . $_POST["txtfname"] . "',";
    $command .= "'" . $_POST["txtlname"] . "',";
    $command .= "'" . $_POST["txtUname"] . "',";
    $command .= "'" . $_POST["txtemail"] . "',";
    $command .= "'" . $_POST["txtpassword"] . "')";

    $result = mysqli_query($con, $command);

    if ($result) {
        echo "<script>alert('The Record has been saved'); window.location='main.php';</script>";
        exit();
    }
}

// CANCEL
if (isset($_POST["btncancel"])) {
    echo "<script>alert('Are you sure you want to  cancelled'); window.location='main.php'</script>";
    exit();
}
?>


<html>
<head>
    <title>Add Record</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: #e6f2ff; /* light blue */
            display: flex;
            justify-content: center;
            align-items: center;
            height: 110vh;
        }
        .form-container {
            background: #ffffff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0px 4px 10px rgba(0,0,0,0.1);
            width: 360px;
        }
        .form-container h2 {
            text-align: center;
            margin-bottom: 20px;
            color: #004080;
        }
        .form-container label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #004080;
        }
        .form-container input {
            width: 100%;
            padding: 8px;
            margin-bottom: 15px;
            border: 1px solid #3399ff;
            border-radius: 4px;
        }
        .form-container button {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            background: #e08ecd;
            border: none;
            color: white;
            font-size: 16px;
            border-radius: 4px;
            cursor: pointer;
        }
        
    </style>
</head>
<body>
    <div class="form-container">
        
        <form method="post" action="add_record.php">
    First Name: <input type="text" name="txtfname"><br>
    Last Name: <input type="text" name="txtlname"><br>
    Username: <input type="text" name="txtUname"><br>
    Email: <input type="text" name="txtemail"><br>
    Password: <input type="password" name="txtpassword"><br><br>

            
            <button type="submit" name="btnsave" >Save Record</button>
            
            <button type="submit" name="btncancel" value="btncancel">Cancel</button>
        </form>
    </div>
</body>
</html>





<?php
$con = mysqli_connect("localhost", "root", "root", "ip_languido_database");

if (isset($_POST["btnupdate"])) {

    $command = "UPDATE tbl_registration SET ";
    $command .= "first_name='" . $_POST["txtfname"] . "', ";
    $command .= "Last_name='" . $_POST["txtlname"] . "', ";
    $command .= "user_name='" . $_POST["txtUname"] . "', ";
    $command .= "email='" . $_POST["txtemail"] . "', ";
    $command .= "password='" . $_POST["txtpassword"] . "' ";
    $command .= "WHERE email='" . $_POST["cloneemail"] . "'";

    $result = mysqli_query($con, $command);

    if ($result) {
        echo "<script>alert('The Record has been Updated')</script>";
        echo "<script> window.location='main.php'</script>";
    } else {
        echo "<script>alert('Update failed: " . mysqli_error($con) . "')</script>";
    }
}


if (isset($_GET["email"])){

$command = "SELECT * FROM tbl_registration WHERE email='" . $_GET["email"] . "'";
$result = mysqli_query($con, $command);

if ($record = mysqli_fetch_row($result)) {
    $first_name = $record[0];
    $Last_name  = $record[1];
    $user_name  = $record[2];
    $email      = $record[3];
    $password   = $record[4];
}}
// CANCEL
if (isset($_POST["btncancel"])) {
    echo "<script>alert('Are you sure you want to  cancelled'); window.location='main.php'</script>";
    exit();
}
?>




<html>
<head>
    <title>edit Record</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: #e6f2ff; /* light blue */
            display: flex;
            justify-content: center;
            align-items: center;
            height: 110vh;
        }
        .form-container {
            background: #ffffff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0px 4px 10px rgba(0,0,0,0.1);
            width: 360px;
        }
        .form-container h2 {
            text-align: center;
            margin-bottom: 20px;
            color: #004080;
        }
        .form-container label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #004080;
        }
        .form-container input {
            width: 100%;
            padding: 8px;
            margin-bottom: 15px;
            border: 1px solid #3399ff;
            border-radius: 4px;
        }
        .form-container button {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            background: #e08ecd;
            border: none;
            color: white;
            font-size: 16px;
            border-radius: 4px;
            cursor: pointer;
        }
        
    </style>
</head>
<body>
    <div class="form-container">
        
        <form method='post' action='edit_record.php'>
            <label>First Name</label>
            <input type="text" name="txtfname"  value="<?php echo $first_name ;;?>" required>

            <label>Last Name</label>
            <input type="text" name="txtlname" value="<?php echo $Last_name;?>" required>

            <label>Username</label>
            <input type="text" name="txtUname" value="<?php echo $user_name;?>" required>

            <label>Email</label>
            <input type="email" name="txtemail" value="<?php echo @$email;?>" required>
            <input type="hidden" name="cloneemail" value="<?php echo @$email;?>" required>

            <label>Password</label>
            <input type="password" name="txtpassword" value="<?php echo $password;?>" required>

          
            <button type="submit" name="btnupdate">Update Record</button>
            <button type="submit" name="btncancel">Cancel</button>
        </form>
    </div>
</body>
</html>


Editor is loading...
Leave a Comment