How to Create an Order Form With PHP
PHP is a versatile programming language for websites. It allows a site to interact with the server to accomplish interactive tasks. An order form is a common example of how PHP can integrate with a Web page to process user information and send an actual order to the site owner. While PHP is not an easy programming language to learn, it's possible to create PHP scripts using preexisting code. Many scripts are available for free online.
Instructions
-
-
1
Find a free online order form (see Resources). Using existing code will obviate the task of learning how to program HTML and PHP yourself. Some forms will process the order form by simply sending you an email with the customer information and order details; others are more robust and store the information in a database or even process credit cards. Choose a form that's appropriate for your business.
-
2
Open a text editor on your computer (a good program to use is Windows Notepad).
-
-
3
Copy and paste the HTML code for the first part of your order form into the blank text file. A PHP order form requires two files. The first is in HTML only and begins with the line "<html>" at the top of the file. It ends with "</html>" as the last line in the file.
-
4
Note the file name that appears in the HTML code "form" tag. For example, the line may say "<form action=process.php." The file name is "process.php." You'll need this file name later.
-
5
Save the text file with any desired file name, but use the ".html" extension. Windows may prompt you with a pop-up warning to indicate that you're changing the file format---accept the change. The name of this HTML file is the same as the URL file name used to access the order form. For example, if you name your form "form.html," it will be accessed later at "http://www.(yourwebsite.com)/form.html."
-
6
Create another new, empty text file.
-
7
Copy and paste the second portion of the order form into this blank file---this will contain the PHP code. All PHP code begins with "<?php." However this statement can appear anywhere within the PHP document, not necessarily at the top.
-
8
Save this file using the same file name as derived earlier from the previous HTML file. If the HTML "form" field used "process.php," save this file as "process.php."
-
9
Open your FTP software; many FTP programs are available for free online (see Resources).
-
10
Connect to your Web-hosting account using the server address provided by your hosting company.
-
11
Drag the two files you created onto the FTP window and drop them into your website directory. The order form is now active on your site.
-
1