HTML.form.guide

PHP Form Handling

How to Use HTML5 Input Type 'file' - With Examples

If you're developing a nice website like Facebook or Youtube where subscribers share images and videos, or you're selling premium content like e-books online, you have to provide a way for users to upload content. In this tutorial, I will show you how to add file uploading capability to your web page like a pro. The W3C HTML Standard defines several <input > types each designed to handle a specific type of data.

Continue Reading →

PHP Form Validation Tutorial

Client-side form validations help in giving immediate feedback to the user. It is also required to add server side form validation in your form processing script. The user can disable Javascript on their server or even auto-bots might try to submit your form as well. The server side form validations help keeping the form submission data consistent. The validations also help in lesser server side errors. For example, if you have set length limit in the database for a text input, it is better to do the validation before it actually gets cut off by the database system or even getting an error thrown.

Continue Reading →

Creating a registration form using PHP

Creating a membership based site seems like a daunting task at first. If you ever wanted to do this by yourself, then just gave up when you started to think how you are going to put it together using your PHP skills, then this article is for you. We are going to walk you through every aspect of creating a membership based site, with a secure members area protected by password.

Continue Reading →

Making a login form using PHP

This is in continuation of the tutorial on making a membership based web site. Please see the previous page PHP registration form for more details. Download the code You can download the whole source code for the registration/login system from the link below: RegistrationForm.zip The ReadMe.txt file in the download contains detailed instructions. The login form Here is the HTML code for the login form. <form id='login' action='login.php' method='post' accept-charset='UTF-8'> <fieldset > <legend>Login</legend> <input type='hidden' name='submitted' id='submitted' value='1'/> <label for='username' >UserName*:</label> <input type='text' name='username' id='username' maxlength="50" /> <label for='password' >Password*:</label> <input type='password' name='password' id='password' maxlength="50" /> <input type='submit' name='Submit' value='Submit' /> </fieldset> </form> Logging in We verify the username and the password we received and then look up those in the database.

Continue Reading →

Creating a multi-page order form using PHP

Forms are part of virtually any web application today. They are the main method to receive input from people using the application. They range in size from one-field opt-in forms where you only enter your email address, to very long forms with tens or even hundreds of fields. To make long forms user-friendlier, it is a good idea to span the form on multiple pages. This can make it easier to follow for the user, and we can also split the data in separate sections, based on the scope (for example separate personal customer information from payment data in a shopping cart checkout form).

Continue Reading →

Handling checkbox in a PHP form processor

This tutorial will introduce HTML check boxes and how to deal with them in PHP. Single check box Let's create a simple form with a single check box. <form action="checkbox-form.php" method="post"> Do you need wheelchair access? <input type="checkbox" name="formWheelchair" value="Yes" /> <input type="submit" name="formSubmit" value="Submit" /> </form> In the PHP script (checkbox-form.php), we can get the submitted option from the $_POST array. If $_POST['formWheelchair'] is “Yes”, then the box was checked.

Continue Reading →

Handling select box (drop-down list) in a PHP form

This tutorial will show you how to add select boxes and multi-select boxes to a form, how to retrieve the input data from them, how to validate the data, and how to take different actions depending on the input. Select box Let's look at a new input: a “select” box, also known as a “drop-down” or “pull-down” box. A select box contains one or more “options”. Each option has a “value”, just like other inputs, and also a string of text between the option tags.

Continue Reading →

How to submit a form using PHP

There are situations when you want to send data using POST to a URL, either local or remote. Why would you want to do this? Probably you want to submit data to an opt-in form, but without taking a valuable visitor away from your site. Or maybe you want to send data to several applications for various purposes, which would be impossible to do in the usual manner. So how can we deal with this problem?

Continue Reading →

Passing PHP form variables from one page to other

This is in continuation of the PHP multi-page order form article. The first paged explained how to pass the variables between pages using sessions. This page shows you how to accomplish the same using hidden fields. Multi-page forms using hidden input fields Hidden input fields are form fields that are not visible. The user can't see or change these fields, and they are used to transmit state information between different pages.

Continue Reading →

PHP form processing

This tutorial will build on the previous PHP form tutorial, introduce some more concepts of PHP form processing, HTML forms and form validation, and instead of saving data to a text file, we will save data to a MySQL database. This tutorial will assume that you've read the first tutorial and that you have a basic understanding of SQL and MySQL. Note: Using Simfatic Forms you can create feature-rich web forms without coding.

Continue Reading →

PHP form tutorial

This tutorial takes you step by step through web form processing using PHP. You will learn how to collect input from a web form, validate and save it. This tutorial assumes that you are familiar with at least very basic PHP and HTML. Note: You can make web forms quickly with Simfatic Forms. Simfatic Forms helps you to make complete, feature rich forms and get it online quickly. Read more here.

Continue Reading →

PHP Form Validation Script

It is very essential to have the input to your form validated before taking the form submission data for further processing. When there are many fields in the form, the PHP validation script becomes too complex. Moreover, since you are doing the same or similar validation for most of the forms that you make, just too much of duplicate effort is spent on form validations. Note: You can make web forms quickly with Simfatic Forms.

Continue Reading →

Using PHP_SELF in the action field of a form

In this article shows the usage of PHP_SELF variable and how to avoid PHP_SELF exploits. What is PHP_SELF variable? PHP_SELF is a variable that returns the current script being executed. This variable returns the name and path of the current file (from the root folder). You can use this variable in the action field of the FORM. There are also certain exploits that you need to be aware of. We shall discuss all these points in this article.

Continue Reading →

Using the GET method in a PHP form

This tutorial will cover how PHP handles form data posted via the ‘GET’ method. Introduction to the query string GET data comes from the URL itself, and will typically follow the name of the script file in the URL. The start of GET data is indicated with a question mark (?). The name of the field is followed by an equal sign (=) and the value of the field. Each field is then separated by an ampersand (&).

Continue Reading →

Using the POST method in a PHP form

This tutorial will cover how PHP handles form data posted via the POST method. Introduction to the form POST data is submitted by a form and “posted” to the web server as form data. POST data is encoded the same way as GET data, but isn't typically visible to the user in standard browsers. Most forms use the post method because it “hides” the form data away from the user and doesn't clutter up the URL in the address bar.

Continue Reading →