How can we receive input value from web page by GET method and store it in MySQL database using php?
We have to do some steps، but before that to use your PC as a server to complete the task, you have to download XAMPP to use Apache Web Server and MySQL Database
Let's say we want a web page to receive an integer, we will create a simple html page (and save it as a php file) you can find the example code from the attachments above getForm.php
The most important thing when writing input form let method="get" and action=(the name of php page)
- Open XAMPP and run Apache Web Server and MySQL Database
- Go to application and open phpmyadmin by searching http://localhost/phpmyadmin/
- From the bar, create a new database ( from new button ), let's say its name is (db)
- Create a table inside the database, let's say its name is (table)
- For our example, we only need one column of type int , let's say its name is (value)
Click Save, now our database is ready!
We write a php file that stores the value of the number entered, and then sends it to the database If the storage task is successful, a message will be displayed (The number ..... has been stored Successfully) you can find the example code from the attachments above get.php
Finally, inside the (xampp >> htdocs) folder you have to create a folder and save two php files in it
Now let's open the first php file with Apache Web Server ( http://localhost/getForm.php ) and enter number 1 for example We will see that the browser has converted us to get.php web and that the url contains the value we entered
And if we open the database, we will find that the number 1 has already been stored!
And that's it!