0% found this document useful (0 votes)
38 views

PHP 8

This document contains PHP code to connect to a MySQL database called "crud_example" and retrieve user data. It includes: 1) A connection file that establishes a connection to a MySQL database using a host, username, password, and database name. 2) An index file that displays a form to add a new user and includes a separate file to read and display existing users. 3) The code connects to a database and displays a basic CRUD interface to add, view, and manage user records.

Uploaded by

maralessiregar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

PHP 8

This document contains PHP code to connect to a MySQL database called "crud_example" and retrieve user data. It includes: 1) A connection file that establishes a connection to a MySQL database using a host, username, password, and database name. 2) An index file that displays a form to add a new user and includes a separate file to read and display existing users. 3) The code connects to a database and displays a basic CRUD interface to add, view, and manage user records.

Uploaded by

maralessiregar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Koneksi.

php

<?php

$host = 'localhost';

$user = 'your_username';

$password = 'your_password';

$database = 'crud_example';

$conn = new mysqli($host, $user, $password, $database);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}
Index.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>CRUD Example</title>

</head>

<body>

<h2>CRUD Example</h2>

<form action="create.php" method="post">

<label for="name">Name:</label>

<input type="text" name="name" required>

<label for="email">Email:</label>

<input type="email" name="email" required>

<button type="submit">Add User</button>

</form>

<hr>

<!-- Display Users -->

<?php include 'read.php'; ?>

</body>

</html>

You might also like