Wednesday, 10 February 2016

A Simple Example Of PHP

Suppose you have a form


  1. <FORM ACTION="/cgi−bin/php.cgi/~userid/display.html" METHOD=POST>
  2. <INPUT TYPE="text" name="name">
  3. <INPUT TYPE="text" name="age">
  4. <INPUT TYPE="submit">
  5. <FORM>
Your display.html file could then contain something like:
<php
 echo "Hi $ name, you are $ age years old!";
?>
It's that simple! PHP automatically creates a variable for each form input field in your form. You can then use
these variables in the ACTION URL file.
The next step once you have figured out how to use variables is to start playing with some logical flow tags in
your pages. For example, if you wanted to display different messages based on something the user inputs, you
would use if/else logic. In our above example, we can display different things based on the age the user
entered by changing our display.html to:

<?php
if($age>50);
echo "Hi $name, you are ancient!<p>";
elseif($age>30);
echo "Hi $name, you are very old!";
else;
echo "Hi $name.";
endif;
?>

PHP give a very powerful scripting language which shall do much many more than what the above simple
example demonstrates. See the section on the PHP Script Language for more information.
You can also use PHP to configure who is allowed to access your pages. This is done using a built−in
configuration screen. With this you could for example specify that only people from certain domains would be
allowed to see your web pages, or you could create a rule which would password protect certain pages. See the
Access Control section for more details.
PHP is also capable of receiving file uploads from any RFC−1867 compliant web browser. This feature lets
people upload both text and binary files. With PHP's access control and logical functions, you have full
control over who is allowed to upload and what is to be done with the file once it has been uploaded. See the
File Upload section for more details.
PHP has support for the PostgreSQL database package. It supports embedded SQL queries in your .HTML
files.
PHP also has support for the mysql database package. It supports embedded SQL queries in your .HTML
files.

0 comments:

Most Trending

2016. Powered by Blogger.

Contact us

Name

Email *

Message *