Ch2
Ch2
1
Objectives
Introducing Arrays
2
Introduction
3
Creating an
HTML Form
• Handling an Html Form with PHP is perhaps the most important process
in any dynamic web sites.
2. You create the corresponding PHP scripts that will receive and the
process the Form data.
4
Continue
• An HTML Form is created using the form tags and various element for taking
input .
</form>
• In terms of PHP, the most important attribute of your form tag is action.
Which dictates to which page the form data will be sent.
5
Choosing a
Method
• The method attribute of a Form dictates how the data is sent to
the handling page.
• The get method sends the submitted data to the receiving page
as a series of name_value pairs appended to the URL.
• The benefit of using the get method is that the resulting page
can be bookmarked in the user’s Web browser (since it’s a
URL).
6
Continue
<html>
<body>
</body>
</html>
8
Continue
• When the user fills out the form above and clicks the submit button,
the form data is sent for processing to a PHP file named
"welcome.php". The form data is sent with the HTTP POST method.
9
GET vs. POST
• Note: GET should NEVER be used for sending passwords or other sensitive information!
10
Continue
• However, because the variables are not displayed in the URL, it is not
possible to bookmark the page.
11
PHP Operators
12
PHP Assignment
Operators
• The PHP assignment operators are used with numeric values to write
a value to a variable.
• The basic assignment operator in PHP is "=". It means that the left
operand gets set to the value of the assignment expression on the
right.
<?php
<?php
$x = 20;
$x = 10;
$x += 100;
echo $x;
echo $x;
?>
?>
13
PHP Increments /
Decrement Operator
• The PHP increment operators are used to increment a variable's value.
• The PHP decrement operators are used to decrement a variable's value.
<?php
$x = 10;
echo ++$x;
?>
14
Comparative
Operators
Symbol Meaning Example
== Is equal to $x=$y
15
Logical Operators
! not !$x
|| Or $x ||$Y
16