SlideShare a Scribd company logo
1 of 23
A Step by Step approach for
PHP-MySQL Connectivity Using XAMPP Server
Step I
Downloading and
Installing XAMPP
What we Require?
1. XAMPP Server(32 bit/64 bit)
2. Editor(Notepad++/Netbeans)
3. Any Latest Browser(Internet
Explorer/Chrome/Mozila Firefox)
• Download Latest Version of XAMPP(32/64 bit,
according to your machine) from apachefriends.org
• An .exe file will be downloaded after few minutes.
•
• Now Double Click on Downloaded exe file of XAMPP. It
will be started to install.
• There can a warning message shown as in following
snapshot. Just click on Ok (because it is related with user
account control, will be discussed later sometime).
• After few minutes, XAMPP will be installed.XAMPP comes with its
Control Panel. This control panel is used to start/stop any service
directly. It will prompt to open Control panel. You can open now or
later on. I will open to check the installation status of XAMPP.
• After clicking on finish, Save appropriate language.
• Now Following snapshot shows XAMPP control panel.
• Now start Apache and MySQL services by clicking on Start Buttons shown
in front of them.Now, lets check the working of server.
• Open any Browser.(I will open Chrome).
• Type localhost in address bar and hit enter.The following screen shows
successful working of XAMPP.
Step II
Creating Database and Table in
MySQL
• Open XAMPP Control Panel.It can be opened by moving to
C:xampp directory.Serach xampp-control file and click on it.
• Now click on Admin button in front of MySQL Module.It will
open MySQL database user interface in default browser as
shown.
• You can create and manage databases in this interface. It can
be also openend by typing http://localhost/phpmyadmin/ in
address bar.
MySQL Database User Interface
Creating Database
• Click on database Tab.
• Now type name of database you want to create.I type
user_account. Then click on create button.
• Now new database with name user_accounts will be created
and shown on the top in hierarchical way.
Creating Table
• Now give a tablename to be created and select number of columns. Click
on go to proceed further.
• I have typed two columns say, user_id and user_passwd for my table.Click
on save to process query. A table will be created as shown.
Step III
Connecting PHP and MYSQL to
insert into table
• Open Notepad++ to type following
coding.Save this file to C:xampphtdocs for
proper working.
Form Coding
Form Coding (user_register.php)
</head>
<body>
<form id="user_register" method="get" >
<div style="text-align:center">
<span class="label success" height="100%"><font size="4">Enter User
Id</font></span>
<input type="text" id="un" name="uname" placeholder="Enter User Name">
<br/>
<span class="label success" height="100%"><font size="4">Enter User
Id</font></span>
<input type="password" id="up" name="upasswd" placeholder="Enter
Password">
<br/><br/>
<input type="submit" name="submit" value="Add User">
Form Coding (user_register.php) cont.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "user_accounts";
//creating connection
$con = new mysqli($servername, $username, $password, $dbname);
//checking connection status
if($con->connect_error)
{
die("Connection Failure:".$conn->connect_error);
return false;
}
Form Coding (user_register.php) cont.
if(isset($_GET['submit']))
{
$u_name=$_GET['uname'];
$u_passwd=$_GET['upasswd'];
$add_qry="insert into
users_tabs(user_id,user_passwd)values('$u_name','$u_passwd')";
if ($con->query($add_qry) === TRUE)
{
echo "User Added"."<br/>";
}
else
{echo "Error: " . $add_qry . "<br>" . $con->error;}
unset($_GET['submit']);
$con->close();
}
?>
</div></form><body></html>
Output
Database Snapshot
Conclusion
• So, hence you can execute every type of query
such as insert, select, delete and update in
MySql.
Thanks

More Related Content

What's hot

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHPTaha Malampatti
 
Javascript alert and confrim box
Javascript alert and confrim boxJavascript alert and confrim box
Javascript alert and confrim boxJesus Obenita Jr.
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorialalexjones89
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requireTheCreativedev Blog
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xamppJin Castor
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to phpAnjan Banda
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHPNisa Soomro
 
Web Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptWeb Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptEdureka!
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 

What's hot (20)

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
Java script
Java scriptJava script
Java script
 
Java Beans
Java BeansJava Beans
Java Beans
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
Java swing
Java swingJava swing
Java swing
 
Javascript alert and confrim box
Javascript alert and confrim boxJavascript alert and confrim box
Javascript alert and confrim box
 
Operators php
Operators phpOperators php
Operators php
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xampp
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
 
Web Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptWeb Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 

Similar to PHP-MySQL Database Connectivity Using XAMPP Server

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhostIIUM
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpaimaq9a
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Boxguest34a3a419
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows BoxJayanta Dash
 
WASPNEWServerDecoumentation
WASPNEWServerDecoumentationWASPNEWServerDecoumentation
WASPNEWServerDecoumentationJames Willis
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationChetan Soni
 
4th quarter 17 php & my sql registration page
4th quarter   17 php & my sql registration page4th quarter   17 php & my sql registration page
4th quarter 17 php & my sql registration pageEsmeraldo Jr Guimbarda
 
How to Install a PHP Script in cPanel.pdf
How to Install a PHP Script in cPanel.pdfHow to Install a PHP Script in cPanel.pdf
How to Install a PHP Script in cPanel.pdfHost It Smart
 
How to Install Magento 2 On Wamp
How to Install Magento 2 On WampHow to Install Magento 2 On Wamp
How to Install Magento 2 On WampTecstub
 
Installation xampp and WordPress on localhost
Installation xampp and WordPress on localhostInstallation xampp and WordPress on localhost
Installation xampp and WordPress on localhostLuzan Baral
 
How to install word press on local server
How to install word press on local serverHow to install word press on local server
How to install word press on local serverHimanshi Garg
 
Install Word Press with xampp
Install Word Press with xamppInstall Word Press with xampp
Install Word Press with xamppMehdi Sharifirad
 
How to Install and Configure Drupal CMS
How to Install and Configure Drupal CMSHow to Install and Configure Drupal CMS
How to Install and Configure Drupal CMSdarandon
 

Similar to PHP-MySQL Database Connectivity Using XAMPP Server (20)

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for php
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
WASPNEWServerDecoumentation
WASPNEWServerDecoumentationWASPNEWServerDecoumentation
WASPNEWServerDecoumentation
 
Web hosting Free Hosting
Web hosting Free HostingWeb hosting Free Hosting
Web hosting Free Hosting
 
Web hosting get start online
Web hosting get start onlineWeb hosting get start online
Web hosting get start online
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and Configuration
 
Installation 02 (wp)
Installation 02 (wp)Installation 02 (wp)
Installation 02 (wp)
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
4th quarter 17 php & my sql registration page
4th quarter   17 php & my sql registration page4th quarter   17 php & my sql registration page
4th quarter 17 php & my sql registration page
 
How to Install a PHP Script in cPanel.pdf
How to Install a PHP Script in cPanel.pdfHow to Install a PHP Script in cPanel.pdf
How to Install a PHP Script in cPanel.pdf
 
How to Install Magento 2 On Wamp
How to Install Magento 2 On WampHow to Install Magento 2 On Wamp
How to Install Magento 2 On Wamp
 
Installation xampp and WordPress on localhost
Installation xampp and WordPress on localhostInstallation xampp and WordPress on localhost
Installation xampp and WordPress on localhost
 
How to install word press on local server
How to install word press on local serverHow to install word press on local server
How to install word press on local server
 
Install Word Press with xampp
Install Word Press with xamppInstall Word Press with xampp
Install Word Press with xampp
 
How to Install and Configure Drupal CMS
How to Install and Configure Drupal CMSHow to Install and Configure Drupal CMS
How to Install and Configure Drupal CMS
 

Recently uploaded

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 

Recently uploaded (20)

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 

PHP-MySQL Database Connectivity Using XAMPP Server

  • 1. A Step by Step approach for PHP-MySQL Connectivity Using XAMPP Server
  • 3. What we Require? 1. XAMPP Server(32 bit/64 bit) 2. Editor(Notepad++/Netbeans) 3. Any Latest Browser(Internet Explorer/Chrome/Mozila Firefox)
  • 4. • Download Latest Version of XAMPP(32/64 bit, according to your machine) from apachefriends.org • An .exe file will be downloaded after few minutes. •
  • 5. • Now Double Click on Downloaded exe file of XAMPP. It will be started to install. • There can a warning message shown as in following snapshot. Just click on Ok (because it is related with user account control, will be discussed later sometime).
  • 6.
  • 7. • After few minutes, XAMPP will be installed.XAMPP comes with its Control Panel. This control panel is used to start/stop any service directly. It will prompt to open Control panel. You can open now or later on. I will open to check the installation status of XAMPP. • After clicking on finish, Save appropriate language. • Now Following snapshot shows XAMPP control panel.
  • 8. • Now start Apache and MySQL services by clicking on Start Buttons shown in front of them.Now, lets check the working of server. • Open any Browser.(I will open Chrome). • Type localhost in address bar and hit enter.The following screen shows successful working of XAMPP.
  • 9. Step II Creating Database and Table in MySQL
  • 10. • Open XAMPP Control Panel.It can be opened by moving to C:xampp directory.Serach xampp-control file and click on it. • Now click on Admin button in front of MySQL Module.It will open MySQL database user interface in default browser as shown. • You can create and manage databases in this interface. It can be also openend by typing http://localhost/phpmyadmin/ in address bar.
  • 11. MySQL Database User Interface
  • 12. Creating Database • Click on database Tab. • Now type name of database you want to create.I type user_account. Then click on create button. • Now new database with name user_accounts will be created and shown on the top in hierarchical way.
  • 13. Creating Table • Now give a tablename to be created and select number of columns. Click on go to proceed further. • I have typed two columns say, user_id and user_passwd for my table.Click on save to process query. A table will be created as shown.
  • 14. Step III Connecting PHP and MYSQL to insert into table
  • 15. • Open Notepad++ to type following coding.Save this file to C:xampphtdocs for proper working.
  • 17. Form Coding (user_register.php) </head> <body> <form id="user_register" method="get" > <div style="text-align:center"> <span class="label success" height="100%"><font size="4">Enter User Id</font></span> <input type="text" id="un" name="uname" placeholder="Enter User Name"> <br/> <span class="label success" height="100%"><font size="4">Enter User Id</font></span> <input type="password" id="up" name="upasswd" placeholder="Enter Password"> <br/><br/> <input type="submit" name="submit" value="Add User">
  • 18. Form Coding (user_register.php) cont. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "user_accounts"; //creating connection $con = new mysqli($servername, $username, $password, $dbname); //checking connection status if($con->connect_error) { die("Connection Failure:".$conn->connect_error); return false; }
  • 19. Form Coding (user_register.php) cont. if(isset($_GET['submit'])) { $u_name=$_GET['uname']; $u_passwd=$_GET['upasswd']; $add_qry="insert into users_tabs(user_id,user_passwd)values('$u_name','$u_passwd')"; if ($con->query($add_qry) === TRUE) { echo "User Added"."<br/>"; } else {echo "Error: " . $add_qry . "<br>" . $con->error;} unset($_GET['submit']); $con->close(); } ?> </div></form><body></html>
  • 22. Conclusion • So, hence you can execute every type of query such as insert, select, delete and update in MySql.