Php Script for Content Form is designed for the Internet Content Management System that enables members to create, update and delete records. It has a variety of features that make it very flexible, including custom form components, content validation rules and effective management of editable properties.
We have created a php script to help automate the process of creating a content form, you may download and use this script on your website. However, we recommend to never run this on an internet more than 50 visits per day as the server auto deletes.
Create a form
We will use HTML tags to create a form. Below is the minimal list of things you need to create a form.
- Opening and closing form tags <form>…</form>
- Form submission type POST or GET
- Submission URL that will process the submitted data
- Input fields such as input boxes, text areas, buttons,checkboxes etc.
The code below creates a simple registration form
<html> <head> <title>Registration Form</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <h2>Registration Form</h2> <form action="registration_form.php" method="POST"> First name: <input type="text" name="firstname"> <br> Last name: <input type="text" name="lastname"> <input type="hidden" name="form_submitted" value="1" /> <input type="submit" value="Submit"> </form> </body> </html>
Viewing the above code in a web browser displays the following form.
- <form…>…</form> are the opening and closing form tags
- action=”registration_form.php” method=”POST”> specifies the destination URL and the submission type.
- First/Last name: are labels for the input boxes
- <input type=”text”…> are input box tags
- <br> is the new line tag
- <input type=”hidden” name=”form_submitted” value=”1″/> is a hidden value that is used to check whether the form has been submitted or not
- <input type=”submit” value=”Submit”> is the button that when clicked submits the form to the server for processing
The action attribute of the form specifies the submission URL that processes the data. The method attribute specifies the submission type.
- This is the built in PHP super global array variable that is used to get values submitted via HTTP POST method.
- The array variable can be accessed from any script in the program; it has a global scope.
- This method is ideal when you do not want to display the form post values in the URL.
- A good example of using post method is when submitting login details to the server.
It has the following syntax.
<?php $_POST['variable_name']; ?>
- “$_POST[…]” is the PHP array
- “’variable_name’” is the URL variable name.
Markup of Our HTML Contact Form
The first step towards creating our own contact form is to code the markup. We’ll start doing that once we have a list of all the elements that we want inside our form. We’ll need an input field for the name of the person who is contacting us, and we’ll need a field for their email address so that we can reply to them if the need arises. We’ll also need an input field for the reason people are contacting you and a
textarea where users can type their message.
If the website you’re managing is very popular, you’ll be getting a lot of emails through the contact form. To make sure that the right people get to read those emails and respond quickly, you need a couple more fields. For instance, you could add a field that can determine which department the visitor wants to contact, like marketing, support, or billing. This information can later be used to route the email appropriately. Ultimately, that might help you reply more quickly and sort the emails more efficiently.
How many fields you add to the contact form depends on the type of website you run, but make sure you don’t overdo it. Forcing visitors to fill out too many details might discourage them from contacting you altogether.
Let’s write the HTML code to add all the fields I just mentioned into our contact form.
Before proceeding any further, I’d like to quickly summarize the meaning of some important attributes in the above markup. The
action attribute in the form determines where the form data needs to be sent. If you don’t have an
action attribute, the data is sent back to the same URL. Here we’ve used contact.php, so the form data will be sent to that script.
name attribute for different input elements in the form is used to access the element values on the server side. For example, in the above form, you can get the name of the visitor contacting you using
$_POST['visitor_name'] in contact.php.
We use the
placeholder attribute to give users a basic idea of the expected input for each field in the form. The
required attribute ensures that no important field is left blank before the user hits the submit button on the form.
pattern attribute is used to enforce some rules on the kinds of values that can go inside certain fields. In our case, we only allow users to use letters and the space character in the names they submit. We also limit the total number of acceptable characters to anything from 3 to 20 inclusive. The pattern that you use will depend on the type of input that you want from users.
The following CodePen demo shows us what our simple contact form PHP looks like with the above markup and a little bit of CSS.
The Best Script For Content Management System In Tabs With Ajax Content Slider (Content Form),CSS3, FontAwesome, Bootstrap. Include the Features: Custom Theme and Style Full Responsive – 100% HTML5 and CSS3 Support – Admin Theme or Full Color Control – Add/Edit/Delete Tabs & Slides Using GUI Page Builder Yootheme Included – 2 Skins: Pink And Blue – Fully customizable with HTML Designer Tool