Store and Fetch Data from your PC’s Hard Drive via HTML & PHP

  • Full name.
  • Phone number.
  • Home address.
  • Email address.
  • Delivery option (yes or no).
<form action="insert.php" method="POST">
<td>Name :</td>
<td><input type="text" name="customername" required></td>
<td>Phone Number :</td>
<td><input type="text" name="phonenumber" required></td>
<td>Home Address :</td>
<td><input type="text" name="homeaddress" required></td>
<td>Email Address :</td>
<td><input type="text" name="emailaddress" required></td>
<td>Delivery :</td>
<input type="radio" name="delivery" value="y" required>Yes
<input type="radio" name="delivery" value="n" required>No
<td><input type="submit" value="Submit"></td>
  • Serve as a validator of mandatory text fields,
  • Establish a connection,
  • Echo statements to indicate if a new record was successfully inserted:
$customername = $_POST['customername'];
$phonenumber = $_POST['phonenumber'];
$homeaddress = $_POST['homeaddress'];
$emailaddress = $_POST['emailaddress'];
$delivery = $_POST['delivery'];

//form validator to ensure fields are not empty
if (!empty($customername) || !empty($phonenumber) || !empty($homeaddress) || !empty($emailaddress) || !empty($delivery)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "customers";

//establish a connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbName);

if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$INSERT = "INSERT Into information (customername, phonenumber, homeaddress, emailaddress, delivery) values (?, ?, ?, ?, ?)";

//prepare statement
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("sisss", $customername, $phonenumber, $homeaddress, $emailaddress, $delivery);
echo "New customer record inserted successfully";
echo '<p><a href="javascript:history.go ( -1); Location.reload ()" title="Return to the previous page">&laquo; Go back</a></p>';


} else {
echo "Please fill out all fields";

Note: the column id is checked for A.I (Auto Increment) as a unique identifier of each newly created record.




EmQuart is an American corporation that provides digital products and technology consulting.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build Your Own Encryption Software in Python — Part 3 Deployment as .exe

In the Debugger’s Arsenal: WinDbg

Discover How To Host a Forex Trading Brokerage Server

A Forex Trader using a VPS to trade

TutorCruncher August 18 Newsletter

Apache Airflow on Docker for Complete Beginners

Information, content, and data architectures

Pancakes — H@cktivityCon CTF Challenge

EnableX Low Code Video Embed: Build Applications, Blazing Fast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


EmQuart is an American corporation that provides digital products and technology consulting.

More from Medium

Setting up node server- Without Express JS

Deploy React App on GitHub Pages Automatically

Leverage The Power Of Node.js For Your Next Web App Development Project

Creating An App Using Laravel WebSockets and NextJs (PART 2)