Web Application Development
Web Application Development
Web Applications
An application that is accessed over a network such as the Internet or an intranet. also mean a computer software p application that is hosted in a browser-controlled environment or coded in a browser-supported language (such as JavaScript, combined with a browser-rendered markup language like HTML) and reliant on a common web b li t b browser t to render the application executable.
CreatedBy:SarangPitale
CreatedBy:SarangPitale
Software Bundles
Software Bundles are Required for q the development of web application. Operating System Programming Language DBMS Application Server
DBMS Ope at g Operating System
Web Application
Application Server
Programming Language
CreatedBy:SarangPitale
LAMP
Linux (operating system) Apache HTTP Server MySQL (d b M SQL (database software) f ) Perl/PHP/Python
WAMP
Microsoft Windows Apache HTTP Server MySQL (database software) Perl/PHP/Python
MAMP
Macintosh Apache HTTP Server MySQL (d t b M SQL (database software) ft ) Perl/PHP/Python
SAMP
Solaris Apache HTTP Server MySQL (database software) M SQL (d b f ) Perl/PHP/Python
FAMP
FreeBSD Apache HTTP Server MySQL (database software) Perl/PHP/Python
XAMPP
X (to be read as "cross", meaning cross-platform) Apache HTTP Server MySQL (d t b M SQL (database software) ft ) Perl/PHP/Python
X(crossplatform) X( l f )
ApacheHTTPServer
MySQL
PHP/PerlLayouts
CreatedBy:SarangPitale
HTTP Response
Web Wb Browser
Client Server
CreatedBy:SarangPitale
PHP
5.3.1
PHP was originally created by Rasmus Lerdorf in 1995. General-purpose server-side General purpose server side scripting language originally designed for web development to produce dynamic web pages. PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module which generates the web module, page document. PHP is installed on more than 20 million websites and 1 million web servers. PHP is used as the server-side programming language on 75% of all web servers. Web content management systems written in PHP include Joomla, eZ Publish, WordPress,Drupal and Moodle. All websites created using these tools are written in PHP, including the g , g user-facing portion of Wikipedia, Facebook, and Digg.
CreatedBy:SarangPitale
CreatedBy:SarangPitale
Step-ByStep-By-Step
Write and execute a simple PHP script Create statements and comments, and name variables Use variables to store values Choose b t Ch between PHP data types PHPs d t t Understand the special NULL data type Read GET and POST form input, and store it in variables Perform calculations and comparisons using operators
CreatedBy:SarangPitale
CreatedBy:SarangPitale
CreatedBy:SarangPitale
CreatedBy:SarangPitale
CreatedBy:SarangPitale
<?php //definevariables $auth true; $auth=true; $age=27; $name='Bobby'; $temp=98.6;//returns"string" echogettype($name); h tt ( ) //returns"boolean" echogettype($auth); //returns"integer" g echogettype($age); //returns"double" echogettype($temp); ?>
CreatedBy:SarangPitale
CreatedBy:SarangPitale
Using Operators
If variables are the building blocks of a programming language, operators are the glue that let you do something useful with them.
CreatedBy:SarangPitale
<?php // retrieve form data in a variable $input = $ $ $_POST['msg']; // print it echo "You said: <i>$input</i>"; ? ?>
CreatedBy:SarangPitale
Passing arrays
<form action=mypage. hpp method=POST> <select name=j_names[] size=4 multiple> <option value=2>John <option value=3>Jay <option value=4>Jackie p <option value=5>Jordan <option value=6>Julia </select> <input type=submit value=submit> </form>
if (is_array($ POST[j names])) ( y($_ [ j_ ])) { echo <b>the select values are:<br> <br>; foreach ($_POST[j_names] as $value) { echo $value . <br>\n; } }
CreatedBy:SarangPitale
CreatedBy:SarangPitale
Sessions
A PHP session variable is used to store information about, or change settings for a usersession. Sessionvariables hold information about one single user, and are user available to all pages inone application.
<?php unset($_SESSION['views']); ?> <?php session_destroy(); ?> <?php session_start(); // store session data $_SESSION['views']=1; ?> <html><body> h l b d <?php //retrieve session data echo "Pageviews=". $_SESSION['views']; ?> </body> </html> y <?php session_start(); (); if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+ 1; else $_SESSION['views']=1; echo "Views=.$_SESSION['views']; ?>
CreatedBy:SarangPitale
PHP Sending E-mails E<?php $to = "[email protected]"; $subject = "Test mail"; $message = "Hello! This is a simple email "; Hello! email. ; $from = "[email protected]"; $headers= "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?>
The PHP mail() function is used to send emails from inside a script. d il f i id i
CreatedBy:SarangPitale
Connecting To Database
The free MySQL Database is very often used <?php $con = with PHP. PHP mysql_connect( localhost peter abc123 ); mysql connect("localhost","peter","abc123"); if(!$con) Before you can access and work with data in { die('Could not connect: ' . mysql_error()); a database, you must create a connection to } the database. database // Create database C d b if (mysql_query("CREATE DATABASE In PHP, this is done with the mysql_connect() my_db",$con)) function. { echo "Database created"; } ; else { echo "Error creating database: " . The connection will be closed as soon as the mysql_error(); } script ends. To close the connection before, use // Create table in my_db database themysql_close() function. y q_ () mysql_select_db("my_db", $con); l l t db(" db" $ ) $sql = "CREATE TABLE Person ( FirstName varchar(15), LastName ( ) g )"; varchar(15), Age int ) mysql_query($sql,$con); mysql_close($con); ?>
Created By:Sarang Pitale
The following example selects the same data as the example above, but will display the data in an HTML table