PHP 4

[ PHP ]

(!!! Teleportom!!!)
: fopen, msql_num_fields, socket_write ...


51. PHP HTML

PHP HTML : PHP HTML, HTML ,   PHP.

1. / HTL-? URL?
2. <input type="image">, $foo.x $foo.y . ?
3. HTML- <form>?
4. HTML- select?

1. / HTL-? URL?

, . , string $data, , . :

  • HTML-. , , htmlspecialchars - .

  • URL: URL . , , urlencode().

51-1. hidden HTML-
<?php
    echo "<input type=hidden value=\"" . htmlspecialchars($data) . "\">\n";
?>

: urlencode() $data, urlencode() . . , (GET POST). GET, POST- /hidden.

51-2. ,
<?php
    echo "<textarea name=mydata>\n";
    echo htmlspecialchars($data)."\n";
    echo "</textarea>";
?>

: , , (escaped) html-.

, GET POST, url- url- PHP. urlencod/urldecod , .

51-3. URL
<?php
    echo "<a href=\"" . htmlspecialchars("/nextpage.php?stage=23&data=" .
        urlencode($data)) . "\">\n";
?>

: HTML GET-, urlencode() .

: htmlspecialchars() URL, URL HTML-. - htmlspecialchars() , URL. PHP URL , urlencoded() .

, & URL &amp;. , , . , URL , htmlspecialchars() URL.

2. <input type="image">, $foo.x $foo.y . ?

submit, :
<input type="image" src="image.gif" name="foo">

, : foo.x foo.y.

$foo.x $foo.y PHP, $foo_x $foo_y. , .

3. HTML- <form>?

<form>, PHP-, <input>, <select> <textarea> :
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">

, , . , :

<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyOtherArray[]">
<input name="MyOtherArray[]">

- MyArray MyOtherArray, PHP-. :

<input name="AnotherArray[]">
<input name="AnotherArray[]">
<input name="AnotherArray[email]">
<input name="AnotherArray[phone]">

AnotherArray 0, 1, email phone.

: HTML . , . 0, 1, 2  3.

. PHP.

4. HTML- select?

select multiple HTML . . , . :
<select name="var" multiple>

:

var=option1
var=option2
var=option3

$var. " form" . :

<select name="var[]" multiple>

PHP, $var , var[] . $var[0], - $var[1] .. count() , sort() - , .

, , JavaScript, [] , . id , :
variable = documents.forms[0].elements['var[]'];


PHP PHP COM
php

: 3119 .

: - |  -