RESTful Post: HTML Form
Page 3
HTML, PHP, MySQL
Enter your user name, password, and favorite color in the form below. This example demonstrates how to use basic RESTful HTML post, in an HTML form, for PHP and MySQL. The end result displays a Web page table derived from the posted MySQL data.
The form's action
attribute, receives the
value tables/post-colors.php
.
The form's method
attribute, receives the
value post
.
When the user taps the form's submit
button,
then PHP file, post-colors.php
, receives
data posted from the form.
See the form's HTML markup, below.
HTML Markup
<!doctype HTML> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Post to PHP</title> <meta name="description" content="Form that posts to PHP."/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <style> @import url(../styles/base.css); </style> <link rel="shortcut icon" href="../../7c.ico" /> </head> <body> <nav> <a class="txt" href="https://code.7Thunders.biz/index.php" title="Home"> Home </a> </nav> <div class="content" > <h1>Post to PHP</h1> <form action="tables/post-colors.php" method="post"> <div>User Name:</div> <input type="text" name="user" value="user"/> <div>Password/Email:</div> <input type="text" name="pwd" value="pwd"/> <div>Favorite Color:</div> <input type="text" name="data" value="blue"/> <div>Submit to Database:</div> <input type="submit" value="Post Data"> </form> </div> <footer> <a class="txt" href="https://code.7Thunders.biz/site-map.php" title="Site Map">Site Map </a> </footer> </body> </html>
Try It!
Try the Post to PHP example described in this tutorial.