![]() ![]() |
The versions of PHP, MySQL and Apache installed on www.hku.hk are as
follows:
| Software | Version |
| PHP | 4.2.3 |
| MySQL | 3.23.54a-max |
| Apache | 1.3.27 |
After your application is processed, a new directory will be created for your departmental account on www.hku.hk. The path name for this new directory is /web/php/<account-name>, e.g. /web/php/cc for the Computer Centre. Then you can develop your web page in PHP or in HTML and you must put your PHP files in this new directory as for the static HTML pages. Bear in mind that those files with PHP codes must be named with the extension .php.
To access the web pages written in PHP, use the URL, i.e. http://www3.hku.hk/<account-name>/... (URL updated on Aug 1, 2005)
A summary of the differences between the default web pages on www.hku.hk and PHP supported web pages is tabulated as follows:
| Default (no PHP support) | with PHP support | |
| URL | http://www.hku.hk/<account-name> | http://www3.hku.hk/<account-name> |
| Directory Path | /web/docs/<account-name> | /web/php/<account-name> |
| Extension | .html, .htm | .html, .htm, .php |
If the use of MySQL is required, an account in the MySQL Database will also be created. Details for MySQL database connection are as follows:
| Hostname | www.hku.hk |
| Port number | default MySQL port (3306) |
| Username | your account name on www.hku.hk |
| Database name | your account name on www.hku.hk |
1) Displaying PHP installation details:
| File named test.php contains the following content: |
| <? phpinfo() ?> |
2) Web-based form to accept 2 values and displaying the entered values
using PHP
| File named input.html contains the following content: |
| <Form name="form1" method="post" action="output.php">
<p>Value 1<input type="text" name="value1" size="10"></p>
<input type="submit" value="submit" name="submit">
|
| File named output.php contains the following content: |
| <?php
$value1=$_POST['value1'];
print "value 1 = $value1 <br>";
?> |
3) Connection to MYSQL -- connect to MySQL, select the database "your_db",
and display data in the table "my_table" in a tabular format.
| File named mysql.php contains the following content: |
| <?php
/* Building MYSQL connection */
/* Sending query to MYSQL */
/* Printing results in HTML */
/* Free resultset */
/* Closing connection */
?> |