You are on page 1of 8

Assignment

:

1. Differentiate $_GET from $_POST variable.
2. Define form ID, method and action.
3. Define CSS Colors and NTH.

Answers:

1.
a. $_GET Variable

The GET Method
In GET method the data is sent as URL parameters that are usually
strings of name and value pairs separated by ampersands (&). In general,
a URL with GET data will look like this:
http://www.example.com/action.php?name=john&age=24
The bold parts in the URL are the GET parameters and the italic parts are
the value of those parameters. More than one parameter=value can be
embedded in the URL by concatenating with ampersands (&). One can
only send simple text data via GET method.

Advantages and Disadvantages of Using the GET Method
 Since the data sent by the GET method are displayed in the URL, it is
possible to bookmark the page with specific query string values.
 The GET method is not suitable for passing sensitive information such
as the username and password, because these are fully visible in the
URL query string as well as potentially stored in the client browser's
memory as a visited page.
 Because the GET method assigns data to a server environment
variable, the length of the URL is limited. So, there is a limitation for the
total data to be sent.
PHP provides the superglobal variable $_GET to access all the
information sent either through the URL or submitted through an HTML
form using the method="get"

<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of PHP GET method</title>
</head>
<body>
<?php
if(isset($_GET["name"])){
echo "<p>Hi, " . $_GET["name"] . "</p>";
}
?>
<form method="get" action="<?php echo $_SERVER["PHP_SELF"];?>">
<label for="inputName">Name:</label>
<input type="text" name="name" id="inputName">
<input type="submit" value="Submit">
</form>
</body>

b. $_POST Variable

The value "multipart/form-data" should be used in combination with the INPUT element. enctype . " . "</p>". PHP provide another superglobal variable $_POST to access all the information sent via post method or submitted through an HTML form using the method="post". Data sent through POST method will not visible in the URL. 2 .  There is a much larger limit on the amount of data that can be passed and one can send text data as well as binary data (uploading a file) using POST.  Since the data sent by the POST method is not visible in the URL. See the section on form submission for usage information. } ?> <form method="post" action="<?php echo $_SERVER["PHP_SELF"].This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). An associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request. $_POST["name"] . Possible (case-insensitive) values are "get" (the default) and "post". type="file". Like $_GET.?>"> <label for="inputName">Name:</label> <input type="text" name="name" id="inputName"> <input type="submit" value="Submit"> </form> </body> 2.get|post This attribute specifies which HTTP method will be used to submit the form data set. Form Attribute action . The POST Method In POST method the data is sent to the server as a package in a separate communication with the processing script. so it is not possible to bookmark the page with specific query. The default value for this attribute is "application/x-www-form-urlencoded". User agent behavior for a value other than an HTTP URI is undefined. Advantages and Disadvantages of Using the POST Method  It is more secure than GET because user-entered information is never visible in the URL query string or in the server logs.This attribute specifies a form processing agent. <!DOCTYPE html> <html lang="en"> <head> <title>Example of PHP POST method</title> </head> <body> <?php if(isset($_POST["name"])){ echo "<p>Hi. method .

CSS Colors CSS has several options for defining colors of both text and background areas on your pages.. when you wanted to create an area with a specific color you were forced to include a table. The default value for this attribute is the reserved string "UNKNOWN". In addition. User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element. The client must interpret this list as an exclusive-or list. in plain HTML when working with tables. With CSS. User agents may use this information to filter out non-conforming files when prompting a user to select files to be sent to the server (cf. accept = content-type-list This attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. For example.e. Note. 3. The value is a space. Or even more useful. you can define an area to have a specific color without that area being part of a table. for each and every table cell.and/or comma-delimited list of charset values. COLOR PROPERTIES Property Values NS IE Color <color> 4+ 4+ transparent 4+ 4+ background-color <color> 4+ 4+ none 4+ 4+ background-image url(<URL>) 4+ 4+ repeat 4+ 4+ repeat-x 4+ 4+ background-repeat repeat-y 4+ 4+ no-repeat 4+ 4+ scroll 4+ background-attachment fixed 4+ background-position <percentage> 4+ <length> 4+ top 4+ center 4+ 3 . i. the server is able to accept any single character encoding per entity received.charset list This attribute specifies the list of character encodings for input data that is accepted by the server processing this form. in plain HTML. accept-charset . With CSS you can simply refer to a certain class in your <TD> tags. This attribute has been included for backwards compatibility. Applications should use the id attribute to identify elements. you had to specify font attributes and colors etc. These options can entirely replace the color attributes in plain HTML. the INPUT element when type="file"). name = cdata [CI] This attribute names the element so that it may be referred to from style sheets or scripts. you get new options that you just didn't have in plain HTML.

For example: . by simply entering the values for amounts of Red.} RGB value You can define colors with the use of RGB values. With CSS you have these options: Common name You can define colors with the use of common names. similar to how it's done in plain HTML.myclass {color:red. Green and Blue. colors can either be entered by name (red.} Hexadecimal value You can define colors with the use of hexadecimal values. In plain HTML.) or by a hexadecimal color code (for example: #FF9900). bottom 4+ left 4+ right 4+ <background-color> 4+ 4+ <background-image> 4+ 4+ background <background-repeat> 4+ 4+ <background-attachment> 4+ <background-position> 4+ Setting colors Basically you have three color options with CSS: 1: Setting the foreground color for contents 2: Setting the background color for an area 3: Setting a background image to fill out an area In the next section we will list the different properties that let you do that.myclass {color:#000000. by simply enter the name of the desired color. background-color:blue. 4 . background-color:#FFCC00. blue etc. For example: .

background-repeat:repeat-x Repeats the image horizontally .255.} Setting background colors Background colors are defined similar to the colors mentioned above. background- color:rgb(51. For example you can set the background color of the entire page using the BODYselector: BODY {background-color:#FF6666.} Setting a background image CSS lets you set a background image for both the page and single elements on the page.51. background- color:rgb(81%.gif).myclass {color:rgb(255.102). background-repeat:repeat Tiles the image until the entire page is filled.but not horizontally.81%).} You can control the repetition of the image with the background-repeatproperty.but not vertically. You can define the background image for the page like this: BODY {background-image:url(myimage.18%.} You can also define RGB colors using percentage values for the amounts of Red.100%. In addition.myclass {color:rgb(100%. background-repeat:repeat-y Repeats the image vertically . Green and Blue: For example: . CSS offers several positioning methods for background images. Positioning a background 5 .For example: .100%). just like an ordinary background image in plain HTML.204). background-repeat:no-repeat Does not tile the image at all.

Background positioning is done by entering a value for the left position and top position separated by a space. background- position: 75px 75px. Setting multiple background values Rather than defining each background property with its own property you can assign them all with the use of the background property.gif). The rules for that are extremely simple: tr:nth-child(even) {background: #CCC} tr:nth-child(odd) {background: #FFF} Month '94 '95 '96 '97 '98 '99 '00 '01 '02 Jan 14 13 14 13 14 11 11 11 11 Feb 13 15 12 15 15 12 14 13 13 Mar 16 15 14 17 16 15 14 15 15 Apr 17 16 17 17 17 15 15 16 16 May 21 20 20 21 22 20 21 20 19 Jun 24 23 25 24 25 23 25 23 24 Jul 29 28 26 26 27 26 25 26 25 6 . the table below has a light gray background for the even rows and white for the odd ones. background- attachment: fixed.gif) repeat-y fixed 75px 75px.} Note: Background fixation is not supported by Netscape 4 browsers. For example. Look at this example: BODY {background:green url(myimage. In this example the image is positioned 75 pixels from the upper left corner of the page: BODY {background-image:url(myimage.} CSS NTH EVEN AND ODD RULES One way to improve the readability of large tables is to color alternating rows. Fixing a background You can fixate an image at a certain position so that it doesn't move when scrolling occurs. BODY {background-image:url(myimage.} Note: Background positioning is not supported by Netscape 4 browsers.gif).

but in this case all we need is that the COL elements are present. starting with the 3rd one. 8. you should not set a background on the rows... 23.) The following rules give the first column a yellow background. etc. EVEN AND ODD COLUMNS The same works for table columns.. The keywords 'even' and 'odd' are just convenient shorthands. and then every second column starting from column 3 a gray one: col:first-child {background: #FF0} col:nth-child(2n+3) {background: #CCC} Month '94 '95 '96 '97 '98 '99 '00 '01 '02 Jan 14 13 14 13 14 11 11 11 11 Feb 13 15 12 15 15 12 14 13 13 Mar 16 15 14 17 16 15 14 15 15 Apr 17 16 17 17 17 15 15 16 16 May 21 20 20 21 22 20 21 20 19 Jun 24 23 25 24 25 23 25 23 24 Jul 29 28 26 26 27 26 25 26 25 Aug 29 28 27 28 28 27 26 28 26 Sep 24 23 23 26 24 24 24 22 21 Oct 20 22 20 22 20 19 20 22 Nov 18 17 16 17 16 15 14 15 Dec 15 13 13 14 13 10 13 11 The background of rows (TR) is drawn in front of the background of columns (COL). for a long list you could do this: li:nth-child(5n+3) {font-weight: bold} This says that every 5th list item is bold. but arbitrary intervals. Sources: 7 . 18. CSS allows not only allow even/odd alternations. For example. HTML provides COL for that. will be bold. but then there has to be an element in the document that corresponds to the column. The table has to start with one COL for every column: <table> <col><col><col><col><col><col><col><col><col><col> <tr><th>Month<th>'94<th>'95<th>'96. the items numbered 3.Aug 29 28 27 28 28 27 26 28 26 Sep 24 23 23 26 24 24 24 22 21 Oct 20 22 20 22 20 19 20 22 Nov 18 17 16 17 16 15 14 15 Dec 15 13 13 14 13 10 13 11 In fact. In other words. so if you want to be sure that the background of the columns is visible. (COL can be used for other things than style. 13. too.

php https://www.html 8 .http://www.org/Style/Examples/007/evenodd.com/php-tutorial/php-get-and-post.tutorialrepublic.org/en/docs/Web/CSS/color_value https://www.w3.org/TR/html401/interact/forms.html https://developer.en.mozilla.w3.