add update delete html and php in sql xampp server
add update delete html and php in sql xampp server
mysql on a xampp server involves several steps.below is a step y step guide to help you to achive
this.
);
<?php
$host = 'localhost';
$db = 'test_db';
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
?>
<?php
include 'db.php';
// Add record
if (isset($_POST['add'])) {
$name = $_POST['name'];
$email = $_POST['email'];
// Fetch records
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CRUD Application</title>
</head>
<body>
<h1>User Management</h1>
<form method="POST">
</form>
<table border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Actions</th>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>
<?php
include 'db.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$user = $result->fetch_assoc();
// Update record
if (isset($_POST['update'])) {
$name = $_POST['name'];
$email = $_POST['email'];
// Check connection
if ($conn->connect_error) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$email = $_POST['email'];
header("Location: index.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit User</title>
</head>
<body>
<h1>Edit User</h1>
<form method="POST">
</form>
</body>
</html>
<?php
include 'db.php';
// Delete record
if (isset($_GET['id'])) {
$id = $_GET['id'];
header('Location: index.php');
?>
This setup provides the basic crud application using php and mysql on a xampp server you can expand up
on this by adding validation styling and more advanced feature as needed.