How to make a form on the website

How to make a form on the website

Digital Hits: 74
The form for the website received big distribution to the Internet. By means of forms make out subscriptions to news, order books, video lessons, different materials. Forms - specially limited areas of the page of the website in which the visitor of the website is offered to enter any information or to select any certain actions from a number of offered. During creation of forms it is possible to manage special scripts, but we will register it manually to understand all technology of work and the structure of a form. It is required to you • 1) Html file of the website • 2) Knowledge of bases of HTML • 3) Knowledge of bases of PHP Instruction 1. We start creation of a form on the website. The form will be the following sample: Full name, password, email address, information medium, type of a course. I.e. the form will be on a subscription for video courses. We open html the file and we begin input of the code. Tag which is responsible for creation of a form - ""form"". We write a tag together with attributes of ""form action=" obrabotka.php" method=" post" name" forma1""". We start creation of elements of a form. Practically all elements become by means of a tag , and its type attribute which is responsible for a data type, for example the text, the password and other. Always we set the name "name" to any of attributes. We register: ""br" "Enter a full name: ""br" ""input type= "" text"" of name= "" fio """ ""br"" Enter the password: ""br" ""input type= "" password"" of name= "" pass """ ""br" "Enter E-mai: l" "br" ""input type= "" text"" of name= "" email """". 2. Further we create an element of the choice of radio of the button. Radio the button is an element of a form which when clicking it the cursor joins, and other radio of the button is switched off. Let's exemplify our form. At the order of a course the choice will consist or of CD or DVDs disks therefore it is necessary to select that that one. The element of the "type" - "radio" attribute is responsible for creation of such button. We will register one and too a name for the sake of appearances of the media therefore we will specify the value attribute in order that the processor could define variable value precisely. We register the code: ""br" "Select version of the information medium: ""br" ""input type= "" radio"" of name= "" disk"" value= "" CD """ of "CD" of "br" ""input type= "" radio"" of name= "" disk"" value= "" DVD """ of "DVD" of "br" If to put the value attribute to the text, at once that value which we assigned to this attribute in the form will be displayed. For example that in the form of a full name there was already any name (value=" a name"). 3. We pass to creation of an element of a form during which it is possible to make several choice. Such elements by means of type=" checkbox" become. We register the code: ""br" "Specify the interesting courses" by "br" ch1 name= "" ""input type= "" checkbox"""" value= "yes" ""A course on creation of the website" "br" ""input type= "" checkbox"" of name= "" of ch2" value= "yes" ""A course on creation of books" "br" If there is desire, then it is possible to put any checkbox by default, for this purpose simply we register the word cheked in a tag of ""input"". We register (value= "yes") as it is specified in the code not to get confused during creation of PHP the file. We register a type of delivery by means of a tag of ""select"" at once: Specify delivery type" by" br" ""select name= "" delivery""" ""option" "Urgent ""option" "Normal ""/select"" ""br" Further we do the field for notes or the user's address. A tag of ""textarea"", attributes of this tag "rows" and "cols" which are responsible for the sizes of this field. Enter the address and the note ""textarea name= "" add_text"" of rows= "" 5"" cols= "" 30 """ ""/textarea" We create the sending button with the help of familiar tags: to Send ""input type= "" submit"" of value= "" """" we do not forget to close a tag ""form" 4. We start creation of the obrabotka.php file, we open and we register ""? If (! isset ($ch1)) {$ch1= "no"; } If (! isset ($ch2)) {$ch2= "no"; } mail ("the recipient's mail"," a subject (the order of a disk for example)"," content of the letter, (the person by the name of $fio the specified password of $pass, specified the e-mail address - $email, selected version of the media of $disc, specified that he wants to see the following courses on a disk: \n a course on creation of the website - $ch1 \n the course on creation of books of $ch2, specified delivery type - $delivery, specified $add_text as a home address and the note.)");?" The form is ready.

Author: «MirrorInfo» Dream Team

Print