3D Gallery with Great Artwork Imagine Logo with Three Colors Beach Cabin 3D Android Tablet with Different Screens Studio Apartment Red Figured Greek Vase on Blue Background Silver and Gold Flashlight Lake on Fire

RESTful Post: Activated PHP File

Page 5

HTML, PHP, MySQL

Overview

Learn to prepare a PHP file that activates when the user submits data through an HTML form.

HTML Form

The form's action property links to file post-colors.php. The forms method property has the value post. Therefore when you select the submit button, this form will post data, from the form, to PHP file post-colors.php.

<form action="tables/post-colors.php" method="post">

When users tap the form's Post Data button, with type submit, post-colors.php executes.

<input type="submit" value="Post Data">

File post-colors.php

Create a PHP file named post-colors.php. File, post-colors.php, will include another file named, functions.php.

File functions.php is user defined. File functions.php defines functions showHeader(), getPostedData(), showData(), getSQL() and showFooter(). We'll cover each function in pages seven and eight, of this tutorial.

The line include('functions.php') adds our user defined file, functions.php, to post-colors.php.

The entire file, post-colors.php follows.

<?php
include ('functions.php');
showHeader("Color Table","../../7c.ico","../styles/base.css");
getPostedData();
showData();
getSQL("TestColors");
showFooter("../post/form-base.php");
?>

Pages six and seven cover file functions.php in detail.

Summary

You learned to prepare a PHP file that activates when the user submits data through an HTML form.

Try It!

Try the Post to PHP example described in this tutorial.


Ads >
Create 3D Games: Learn WebGL Book 2 Simple Shaders: Learn WebGL Book 4
3D Programming for Beginners: Learn WebGL Book 1

for Web graphics!

Copyright © 2022 Amy Butler. All Rights Reserved.