How to Connect HTML Form with MySQL Database using PHP

Technical Babaji (Tarique Akhtar) · 2.9M views · 2019 · 7:09

Open on YouTube

Web developmentDatabases & storagetutorial

Why Stack Overflow recommends it

Stack Overflow users, mostly beginners asking about forms that will not insert into MySQL, cite it as the walkthrough they followed when their own setup failed.

Recommended by 0 people across 0 different months, 2019 to 2023.

What it is

A short beginner tutorial that shows how to submit an HTML form to a PHP file and store the data in a MySQL database. It covers the form's action attribute, GET vs POST, reading $_POST, opening a MySQL connection, and using prepared statements with bound parameters to avoid SQL injection. Presented by Technical Babaji (Tarique Akhtar), with source code on GitHub.

What people said

Cites DisabledWhale · 2019-09 · Stack Overflow · on “PHP: Can't insert more than 1 record to database based on web form”

Solution found : I had to set my #ID column to auto_increment. See also: Auto increment in phpmyadmin [LINK] I have made a web formula and I want to fetch the data and insert it in a MySQL database. I am new to PHP and MySQL and I am having some trouble understanding why I can't insert more than 1 row. I have basically just made the following in order to learn to fetch form data: [this video] The guy from the video succeeds at inserting more records from the formula. NB: I am not running on localhost but on a web hotel (with Linux). Part of my troubleshooting: I have differed from procedural- and object-oriented programming and searched StackOverflow to find a way to handle indexes - but i guess

Cites Danie Moller · 2020-04 · Stack Overflow · on “trouble sending to php database”

hi there i have a form and needs to send data to the database but every time i click submit than the page diverts me to the php page i created any help please i have tried the following [LINK] [LINK] [LINK] [LINK] [LINK] [this video] [LINK] [LINK]

Cites Value_Investor · 2023-03 · Stack Overflow · on “How to resolve a 405 status code error when using PHP POST method?”

In one of my HTML files, some data is sent to a PHP file using the POST method. See below for the HTML. <!DOCTYPE html> <html> <head> <title> Test </title> </head> <body> <p> Fill in your e-mail address. </p> <form action="test_db.php" method="post"> <label> E-mail<input type="text" name="email" /> </label> <button>Submit</button> </form> </body> </html> And the PHP file currently only has a very simple task: to display the variable passed to it via the HTML form. See below. <?php // Save input $email = $_POST["email"]; // Display var_dump($email); ?> However, when I run the code in Visual Studio Code, and when I fill in the form, I get the error "This page isn’t working", with a 405 status