Workflow

First, let's create the database and table to store the contact information. We will use a database called "contacts" and a table called "contact_list". The table will have two columns: "name" and "phone".

CREATE DATABASE contacts;

USE contacts;

CREATE TABLE contact_list (
  id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  phone VARCHAR(20) NOT NULL
);

Next, let's create the HTML form to add a new contact. We'll create a file called "create.php".

<!DOCTYPE html>
<html>
<head>
	<title>Add Contact</title>
	<style>
		input[type=text], input[type=tel] {
			margin-bottom: 10px;
			padding: 5px;
			font-size: 16px;
			border-radius: 5px;
			border: none;
			border: 1px solid #ccc;
			width: 100%;
			box-sizing: border-box;
		}

		input[type=submit] {
			background-color: #4CAF50;
			color: white;
			padding: 10px 20px;
			border: none;
			border-radius: 5px;
			cursor: pointer;
		}
		a {
			color: #4CAF50;
			text-decoration: none;
		}
	</style>
</head>
<body>
	<h2>Add Contact</h2>
	<form action="process.php" method="POST">
		<label for="name">Name:</label>
		<input type="text" id="name" name="name" required>

		<label for="phone">Phone:</label>
		<input type="tel" id="phone" name="phone" required>

		<input type="submit" value="Add Contact">
	</form>
	<br>
	<a href="show.php">show Contact</a>
</body>
</html>

Now, let's create the PHP script to process the form and insert the new contact into the database. We'll create a file called "process.php".

Next, let's create the "show.php" page to display the list of contacts.

This code fetches all the contacts from the database and displays them in a table with columns for name, contact number, edit button and delete button for each contact. The edit and delete buttons are links that redirect the user to the update_form.php and delete.php pages respectively, with the contact's ID passed as a parameter in the URL.

Next, let's create code for the update functionality

And finally let's code for deleting a contact

Last updated