Skip to content

alaserimaha/Save-HTML-Form-value-to-MySQL-using-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Save HTML Form Value to MySQL using PHP

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

Xampp_logo svg

click here to download

1. Create a web page to receive input.

2. Create a database to store the entries.

3. Create a php page to connect a web page to a database.

1. Create a web page to receive input.

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)

getForm.php

2. Create a database to store the entries.

  1. Open XAMPP and run Apache Web Server and MySQL Database
  2. Go to application and open phpmyadmin by searching http://localhost/phpmyadmin/
  3. From the bar, create a new database ( from new button ), let's say its name is (db)
  4. Create a table inside the database, let's say its name is (table)
  5. 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! database

3. Create a php page to connect a web page to a database.

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

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

‏urlphoto

And if we open the database, we will find that the number 1 has already been stored!

database

And that's it!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published