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.
<title>Embedding PHP in HTML</title>
<?php echo “Hi, I can easily be embedded into 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.
<title>IP Address of visitor</title>
Your IP Address is : <?php echo $_SERVER[‘REMOTE_ADDR’]; ?>
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”>
Now we will see how values of these fields can be accessed using PHP.
Name: <?php echo $_POST[‘name’]; ?>
Phone: <?php echo $_POST[‘phone’]; ?>