Hi guys, In my
previous post, We explored the XAMPP server and seen how to run the web application in the local machine.
Today we are going to dig into Databases, Yes! Every application is required with backend support i.e., database. For example whenever we try to book our tickets on IRCTC website it looking for user credentials, Once we gave our details it will do backend validation. Anyone wonders how this is works?
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_dC-d0vAcPhJJwRQpm99rJG46wHCtEYNMDucmzIwxKtPbHX7NOM22S4ipo_QEXu8Z2GBCnhyopkfibEhcGSBYzR4p7iV9krzrsf0URcCt2zDTyhkQvBBEtaKUKxwz8BRRdlyIkN94qziO/s400/clientserver.png) |
Simple Client-Server Architecture |
How Database works?
- A client need initiates the request through a web browser on a client machine requests a page from the Web site. The request travels across the Internet based on the requested URL.
- Based on request the application server runs the requested application, which probably needs data from the database server. i.e., Login Server
- The application server needs to make a request to the database server, including security information.
- Once the request passes security and is processed, the database server returns the requested information to the application.
- The application creates a web page and sends it to the Web server which sends it back to the requesting Web browser.
Let's see in action
Inside the XAMPP, we have an option called MYSQL. By click start button, your database turned into green color stating that database is in an active state.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYxcoRR226gU78nXcDiTty1qLPfdHtb_mva2oPgGcKNpqHH_QmdAIJtIN1O7TTWn1A37ikdyGzSKvXQuF0jLfgFN-zUH2rbh2Y-9RnqFaQ6FedTA9sLmVbit_kzr6gI_pNvHaOCeFErQmb/s400/mysql.PNG) |
XAMPP control panel |
Once its get started, click the Admin button to view the phpmyadmin interface
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFIdKJKMlta2_4ivJTNJJEtAZu81bskn1-OH5oqiv7mL9a8OiME445KVJDEgh-kcv1sVwBhuShcF0Fj-03uPXK8A6hrAArSV7KK-iUKx_Vmu-HM3HCJJk8OAM0BEF49_3RJMn5C8b7I6Y/s640/database_launching.PNG) |
phpMyAdmin Interface |
Click the Database tab, Create Database with the name "
SampleDB".
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkP_5gm0xZiGOnKoEL6GkGSBP0loA_Wgnm35ZupCG0yHil0kfL-eBctyzpQ3Z-626p2jCCfhY1PIa0HnW-6rm09ISBM5m-S5QVmcfjJqXXppOwfx8GgAaUkqIil8TrrPrtlnOp5v2hedPR/s640/dbCreation.PNG) |
Creation of database in phpMyAdmin |
Once Database Created, Its time to create to a table structure. Creating the table with name "sampletable" under the
SampleDB along with the number of columns.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_KCA8_qjJDijeFNbGNK6vY5xs-r2YD-ooUyb0Pb4ev_cM3FOX-giuEa3FrtPSE3x4qZoqeP5ftY2Fc8VJRcmnAOYtFe4Dqu3FZbUzgI2Cm-WCGY_FF3RtMGuth4Jak6ETqMffnRJ2bo_C/s640/tableCreation.PNG) |
Creation of Table |
After the creation of a table, we need to create the columns names. In this article, we are creating a database for validating the user credentials so I created two column username, password respectively.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicKl6H1wsfXO0zAQ_UL3aFptIF4Re5oIKfZaCEmwM9jU4Sp5REdUsded5wqyquRlvg0zWerj0U2AkGQA-DBoQwJFWBpBza1tKPomfAbAGYBsdOLdL2fCCykita39a015lpNREpvsBX8BiE/s640/tableStructure.PNG) |
sampletable structure creation
|
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhliicxbYlvCFNk9THnclcH92QmblygzJlGRMlp-eaTvbm9tHMkPQBY2YF1x9Ktfx_St4D_Ip7LNyv3mFKRmBw2I8atBeA4D-yMAagU7cMn6p3iVEUBEpkeXgrMEwKDmpbOUu61uf59-91n/s640/tableCreation%25232.PNG) |
SampleTable Structure with two columns |
For the demo purposes created a sample record which will validate through the web application.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGQS-h0pygpmUSz6j3AMSCQYvgCU_qtt6biiKoBUGBSk4MKiIuyqRwdGyQC6BEfnY92F_OTwG0-DkPfc94kGl73zujjeUQiErRsunKdWFHgebWGuAsAdLkoW31k5KGG9ENnUFZ0VqCE2Yg/s640/samplerecord.PNG) |
Dummy record created under the "sampletable" Table |
Now, Its time to create a simple login web interface using HTML.
Copy the code and run it in the web browser.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcBicRruC3TFOLCosycBlYTQpy4_axIpYPB44dSZjvfj598hHJzbGHfc8xknCwiDkIclU1MyCpmDmm2KN1GtJG4TN0i9plHBxGjG5A_uiAOdZzeJLivo2foJuGf0aLvO9jjVTVrCBCaaXu/s400/loginScreen.PNG) |
Login Screen |
Next, Create a server-side action (code ) to access the database. There are plenty of server-side languages used by developers. We will see those languages in detail in
the upcoming post, now am using PHP.(any way will give you short description below 👇.)
Short Intro to PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.PHP is a server scripting language and a powerful tool for making dynamic and interactive Web pages.
create a PHP file named "action_page.php" under the Page folder.
The above PHP code taking value from HTML and validating with database value which we created and by hitting submit button php start doing its action and showing the output for us
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyMzAgNNENi8eXy44Bz8eJkLf3Tqn3ALdjF246J_kiwtD0eRFzr7IRPTSutTrvgQojh4nbpf2dk1Kp1t8-kSjqH4cdqcyBzznz9TPC_9pr7i_Gw_dWbzve7fsG9IyZgu-wozv2CPjLm6PV/s400/output.PNG) |
action_page.php Output Screen |
Awesome you made it again. Successfully integrated the phpmyadmin database with your simple login web page.
If you have any doubts in this article, please leave your comments .see you in next post
This is Sachin. I was going thru your both blogs and would like to discuss something which you might be interested in. Kindly prompt me on my email address in case you see my message and would like to contact me.
ReplyDeleteE-Mail= srivastavasachin120@gmail.com