Install And Configure XAMPP Server With Data Insert Into Database

Introduction

XAMPP stands for Cross-Platform (X), Apache (A), Maria DB (M), PHP (P) and Perl (P). It is developed by friends of Apache. XAMPP Server is a local WebServer to run the scripting language (PHP, PERL) and this is open source. It includes Apache and MySQL, FileZilla, Mercury and Tomcat.

Here, I am going to show how to create a database and insert the data into the database, using XAMPP Server.

Requirements

  • XAMPP Server
  • Brackets (IDE)
  • Little bit of Web development knowledge

Steps which should be followed are given below.

Carefully follow my steps to create a database and insert the data into the database, using XAMPP Server and I have included the source code given below.

Step 1

Download the latest version of Windows XAMPP Server from the Webpage given below.

Download link: https://www.apachefriends.org/download.html


Step 2

Select your language and click Next.


Step 3

Choose your destination folder.


Step 4

Select all the Services, followed by clicking Install.


Step 5

This is XAMPP Control panel. Start Apache and MySQL Server. Now, provide the permission for Apache and MySQL accesses the firewall.


Step 6

Open your Browser, followed by typing http://localhost or http://127.0.0.1. Afterwards, you will see XAMPP community page.


Step 7

Open the XAMPP Control Panel, followed by clicking MySQL admin.


Step 8

Create the new database and click New.


Step 9

Put the database name as whatever you want. Here, the database name tutorial is given. Click Ceate.


Step 10

Go to SQL query tab, copy and paste the query given below. Click Go. Afterwards, your table (my table name : person) creates successfully.

MySQL query

  1. CREATE TABLE `person` (  
  2.   `Id` int(11) NOT NULL,  
  3.   `Namevarchar(20) NOT NULL,  
  4.   `Email` varchar(25) NOT NULL  
  5. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;   

 



Step 11

Put your Webpage files into the destination folder. Default folder is c:/xampp/htdocs.


Step 12

Open the bracket (IDE) and create the index.html file. Copy the code given below and paste into index.html.

Index.html

  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <title>  
  5.             Xampp Tutorial  
  6.         </title>  
  7.       <style>  
  8.           h1{  
  9.               color: rebeccapurple;  
  10.               font-family: fantasy;  
  11.               font-style: italic;  
  12.           }  
  13.         </style>  
  14. </head>  
  15. <body>  
  16.     <h1>Xampp Tutorial</h1>  
  17.     <hr>  
  18.     <form action="insert.php" method="post">  
  19.             <fieldset>  
  20.                 <legend>enter the details below</legend>  
  21.                 <label>Name</label><br><br>  
  22.                 <input type="text" placeholder="ex:john" name="Name">  
  23.                 <br><br>  
  24.                   
  25.                 <label>Email</label><br><br>  
  26.                 <input type="email" placeholder="hello@gmail.com" name="Email" >  
  27.                 <br><br>  
  28.                 <input type="submit" value="insert">  
  29.             </fieldset>  
  30.         </form>  
  31.     </body>  
  32. </html>  

 



Step 13

Create the insert.php file. Copy the code given below and paste into insert.php.

insert.php

  1. <?php  
  2.   
  3. $con = mysqli_connect('127.0.0.1','root','');  
  4.   
  5. if(!$con)  
  6. {  
  7.     echo 'not connect to the server';  
  8. }  
  9. if(!mysqli_select_db($con,'tutorial'))  
  10. {  
  11.     echo 'database not selected';  
  12. }  
  13.   
  14. $Name = $_POST['Name'];  
  15. $Email = $_POST['Email'];   
  16.   
  17. $sql = "INSERT INTO person (Name,Email) VALUES ('$Name','$Email')";  
  18.   
  19. if(!mysqli_query($con,$sql))  
  20. {  
  21.     echo 'Not inserted';  
  22. }  
  23. else  
  24. {  
  25.     echo 'Data Inserted';  
  26. }  
  27. header("refresh:3; url=index.html")  
  28. ?>  



Step 14

Run index.html. Give the name and an E-mail Id.


Step 15

The data is inserted. Afterwards, go the database and check it.


Step 16

Go to the tutorial database. Open the person table.name and an email id was inserted successfully.

Output


Here, our message is inserted in dynamic Webpage, which has been created and executed. I will continue my next article to give you an in-depth knowledge about XAMPP, FileZilla and GitHub lessons. 

Source code

https://github.com/GaneshanNT/message-insert-into-database