Php basics-part 1PHP – Hypertext Preprocessor
Why php?1.PHP is a Platform Independent language.
2. PHP does not follow the OOP paradigm entirely. It only supports partial encapsulation, and partial polymorphism.
3. PHP is recommended because it is highly reliable, secure and fast than ASP.
Advantages of PHP:-> PHP is one of the most popular server side scripting languages running today.
-> PHP is used for creating dynamic webpages that interact with the user offering customized information.
-> PHP run very fast, secure. Easy to understand
Syntax for a basic PHP Script: <?php and ends with ?>.
<?php
Statements;
.
.
.
?>
A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
<html>
<body>
<?php
Statements;
.
.
?>
</body>
</html>
POST METHOD: If you use “POST” method in HTML file,
you must use “POST” in PHP file.
REQUEST METHOD: If you use “GET” or “POST” in HTML file,
you can use “REQUEST” in PHP file.
A simple example which u can work out.1.Basic instructions before that...1.Install either LAMP Server or WAMP server.
2.These two are available for free.
3.Then go to START->Wampserver->StartWampServer
4.After that save the html and php files in C:(or location where wamp is installed)/wamp/www/
5.This is how to run the program.
Steps to create the simple code n to run it.1.Open the note pad, type the following, then save it as
form1.html in wamp/www/html
EXAMPLE:Form1.html
<html>
<head><title>FORM1</title></head>
<body>
<form action=“form1.php” method=“get”>
Name:   <input type=“text” name=“un”>
<br><br>
Password:   <input type=“password” name=“pw”>
<br><br>
<input type=“submit” value=“Enter”>
</body>
</html>
2.Then type the following separately n save it as
form1.php in wamp/www/html
Form1.php
<?php
echo $_GET[“un”].”<br>”;
echo $_GET[“pw”].”<br>”;
?>
To run this
Step 1: Open the server home page…
and give
http://localhost/filename.html ex:
http://localhost/form1.html Then,
Name: ABCD
Password:efgh
Step 2: After you click submit button you will get the following output…
ABCD
efgh.