Download presentation
Presentation is loading. Please wait.
Published byBerniece Bryant Modified over 9 years ago
1
PHP Form Introduction Getting User Information Text Input
2
Handling User Input In this example we will have two files. –For simplicity sake the first one will be an HTML file known as a form (it will have no PHP code). –The second file will be a PHP file that has variables that get their values from data entered by the user on the first file.
3
Make an HTML file like that below.
4
The code behind so far
5
Add the tag with name, action and method attributes
6
Another approach: Insert/Form/Form
7
Supply action, method and name attributes
8
Any input element should be between the tags, so I moved the close form tag to the bottom of the page.
9
Highlight both cells in the seconds row and then go to Modify/Table/Merge cells
10
Enter Text in the table cells
11
Go to Insert/Form/Text Field
12
Supply an id and a tab index. (The label is for associated text, but we placed that in another table cell.) The tab index will allow the user to click the tab button to progress through the form without using a mouse.
13
Result (with size attribute) in code and design Note the name and id attributes are both set to txtFirstName. JavaScript usually uses id and PHP uses name.
14
Add another input text field, then place the cursor after the table but inside the form and go to Insert/Form/Button
15
Enter value for the type, name and value
16
Submit code in Code and Design
17
Adding some style to the button
18
Starting the PHP code that handles the form data This code takes the data associated with the form and its post method and assigns the values to the PHP variables $firstName and $lastName. Remember PHP variables start with a dollar sign.
19
Code to display user’s information This code uses the concatenation operator, which in PHP is a period.
20
Form and Form handler
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.