PHP (Hypertext Preprocessor) ia an Open Source general purpose web scripting language. It is widely used for Web development because it can easily be embedded into HTML. PHP is an easy to learn and you can start developing dynamic webpages very quickly. Moreover PHP can be used in other development areas e.g Command line scripting.
<html>
<head>
<title>Embedding PHP in HTML</title>
</head>
<body>
<?php echo “Hi, I can easily be embedded into HTML !!!”; ?>
</body>
</html>
PHP can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor.
Retrieving IP Address of visitors
You can see from the example above how easily PHP code can be embeded into HTML. Now let us see something more useful. We will check the IP address of the visitor of the page. This can be achieved using PHP as follows.
<html>
<head>
<title>IP Address of visitor</title>
</head>
<body>
Your IP Address is : <?php echo $_SERVER['REMOTE_ADDR']; ?>
</body>
</html>
Working with forms
Here we will see how to use PHP in working with HTML forms. We will see how one can use PHP to access data filled in HTML forms. Let us have form with Name and Phone Number fields as below.
<form action=”action.php” method=”post”>
Name: <input type=”text” name=”name”>
Phome: <input type=”text” name=”phone”>
<input type=”Submit” value=”Submit”>
</form>
Now we will see how values of these fields can be accessed using PHP.
Name: <?php echo $_POST['name']; ?>
Phone: <?php echo $_POST['phone']; ?>
November 27, 2007 at 2:48 pm |
[...] cookie values at server. At server in PHP script, cookies sent from the client browser will be turned into PHP variables. After PHP 4.1.0 the global [...]