How Build a Simple HTML Form Using PHP and MySQL

John Morris · 313K views · 2014 · 32:21

Open on YouTube

Web developmentDatabases & storagetutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a starting-point walkthrough when someone needs to learn how to save HTML form data into MySQL with PHP, and several askers say they followed it before getting stuck.

Recommended by 1 people across 1 different months, 2015 to 2016.

What it is

A 32-minute beginner tutorial by John Morris that builds a PHP form from scratch and stores the submitted data in a MySQL database. It covers the basics of handling form input in PHP and connecting to a database, with source code provided.

What people said

Recommends Nathan Plowman · 2016-01 · Stack Overflow · on “How to get checkboxes remained checked after being checked in another device”

Hi Nigel, Yes, for this code to work, you will need to update the value in the database. If you have not done so already, you will need to create a submit handler that will capture the form values and use them to update the value in the database. A complete explanation of how to do this is beyond what I can provide in a comment, but there are lots of tutorials you can find online. Here is a video tutorial I founded that should get you pointed in the right direction: [this video]

Cites Muhammad Ali · 2015-08 · Stack Overflow · on “PHP Contact form connects but does not submit”

Hi there guys this is my PHP for a contact form. It connect succesfully as I ran some tests at various points to see if it worked however it does not seem to submit to the database. Can anyone help me? <?php define('DB_NAME', 'x'); define('DB_USER', 'x'); define('DB_PASSWORD', 'x'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use' . DB_NAME . ': ' . mysql_error()); } $value = $_POST['UserName']; $value1 = $_POST['UserEmail']; $value2 = $_POST['UserMessage']; $sql = "INSERT INTO ContactUs (UserName, UserEmail, Use

Cites m_schou · 2015-10 · Stack Overflow · on “Local host setup with MAMP & phpMyAdmin. File not found on this server”

How do i get my local .php file to show up, so i see my form. When i write local host and then path of .php file i get "Not Found" page. If i add :8889 to local host it seems to run via MySQL-port(8889) instead of Apache-port(8888) and then safari just downloads the file to my downloads. Here i have attached an images that shows all my settings. I use MAMP, phpMyAdmin and i follow the guide of this guy ( [this video] (17.05=troubleshooting)) Here is the code he use (i have copied his source code) The communication to MySQL: <?php define('DB_NAME', 'demo'); define('DB_USER', 'root'); define('DB_PASSWORD', 'root'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)

Cites Andre Debuisne · 2016-04 · Stack Overflow · on “PHP form in HTML, won't connect”

So I am very new to PHP,and databases in general, so please be indulgent! :) I created a simple form in an HTML file: <h1> Créez votre compte ici</h1> <form action="form.php" method="post"> <p id="textdone"> </p> <input type= "text" name="Surname" autocomplete="on" placeholder="Votre nom" required/> <br> <br> <input type= "text" name="Name" autocomplete="on" placeholder ="Votre prenom" required/> <br> <br> <input type= "email" name="Email" autocomplete="on" placeholder ="Adresse mail" required/> <br><br> <input type= "text" name="Pseudo" autocomplete="off" placeholder ="Votre pseudo" maxlength="20" required/> <br> <p>Ajoutez une photo de profil: <input type= "file" /> <br><br></p> <p> Entrez