Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,361
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
53
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Introduction to Open source PHP & Joomla Asst. Prof Roshni M. Raval
  • 2.  
  • 3. What You Should Already Know
    • HTML/XHTML
    • JavaScript
    • CSS
  • 4. HTML For describing web pages
  • 5. What is HTML?
    • HTML stands for H yper T ext M arkup L anguage
    • For describing web pages.
    • Not a programming language, it is a markup language
    • A markup language is a set of markup tags
    • HTML follows w3c rules.
    • Div based code.
  • 6. Java Script Is a Library for interactive UI and client side validation
  • 7. Why JavaScript?
    • JavaScript is a scripting language
    • JavaScript was designed to add interactivity to HTML pages
    • Lightweight programming language
    • Embedded directly into HTML pages
    • Interpreted language (means that scripts execute without preliminary compilation)
    • Everyone can use JavaScript without purchasing a license
    • jQuery
  • 8. ..continue
    • JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as.
    • Internet Explorer
    • Firefox,
    • Chrome,
    • Opera,
    • and Safari.
  • 9. What JavaScript can do?
    • JavaScript gives HTML designers a programming tool.
    • Can put dynamic text into an HTML page.
    • Can react to events.
    • Can read and write HTML elements.
    • Can be used to validate data.
    • Can be used to create cookies.
  • 10. CSS CSS stands for C ascading S tyle S heets
  • 11. What is CSS?
    • Styles define how to display HTML elements.
    • External Style Sheets can save a lot of work.
    • External Style Sheets are stored in CSS files.
  • 12. PHP H ypertext P re p rocessor
  • 13. PHP Introduction
    • PHP is a server-side scripting language.
    • PHP is a powerful tool for making dynamic and interactive Web pages.
    • PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
    • Script execution results are sent to a browser as an HTML page
    • PHP is a type-less language
  • 14. PHP Structure
    • Tradition: Start with an HTML file
    • Add special tags to separate PHP code from HTML statements
    • (i.e. <?php
    • ……
    • ?>)
    • Web server parses the PHP file, producing HTML
  • 15. Example: myfirst.php
      • <html>
      • <body>
      • <?php
      • //A comment
      • /*Or comment like this*/
      • print(&quot;<b>Hello world</b>&quot;);
      • $v = 5;
      • print(&quot;<p>Hello again &quot; . $v );
      • print(&quot;<p>Hello a third time $v&quot;);
      • ?>
      • </body>
      • </html>
  • 16. Variables
    • All variables start with a dollar sign, $
      • $u = 5;
      • $v = “hello”;
      • $w = 1.22;
      • $x = $u + $v; //arithmetic with + - ONLY
      • $y = $v . $v; //concatenation with period operator
      • $x = $u . $u; //produces 55, not 10
  • 17. Printing
      • $u = 5;
      • print( “5 hello” ); //print anything in quotes
      • print( $u . “hello” ); //prints 5hello
      • print( “$u Hello” ); //prints 5 Hello
      • echo ‘Hello’;
      • echo ‘Hello’ . $u;
  • 18. String-Related Functions
      • $v = “hello”;
      • strlen( $v); //returns 5
      • trim( $v); //trims any spaces on either side of a string
      • $x = strtolower ($v); //$x has hello
      • $x = strtoupper($v); //$x has HELLO
      • $str = “abcdef”;
      • $a = substr( $str, 3, 3 );
    # of characters to copy Start position, zero indexed Source string “ def” Can be negative to start from right side
  • 19. Getting HTML Form Data
    • There are 3 ways to get form data in PHP
      • Global variables – this is a bad way because of security problems. PHP creates a variable with a name matching the form field name in the source HTML.
      • POST variable associative array
        • Prior to version 4.1, $HTTP_POST_VARS
        • 4.1 and after,
        • $_POST
      • GET variable associative array
        • Same as POST, but use GET
  • 20. Examples
    • Global variables (HTML has field with name ‘abc’)
        • print ($abc);
    • POST
        • print($_POST(‘abc’)); //4.1 and after
    • GET
        • print($_GET(‘abc’)); //4.1 and after
  • 21. Comparing Strings
    • strcmp( $a, $b ); //works like C function
    • Returns:
    • – 1 if first string less than second string
    • 0 if the same
    • 1 if first string greater than second string
    • It is case sensitive
  • 22. PHP Syntax Similarities
    • Has a switch statement
    • for loop is the same, but uses PHP variable syntax
      • for ($i=0; $i < 10; $i++ ){ …. }
    • while and if are also what you’d expect
    • Standard logical operators: ==, &&, <, > …
  • 23. Other Useful Functions
    • round ($a); //rounds a number
    • is_numeric($v); //returns true/false
    • rand($start, $end); //Produces int rand
  • 24. Creating Functions
      • function myfunc( $a, $b, $c ) {
      • //this is my code
      • return $x;
      • }
  • 25. External PHP Files
    • Can use require or include
      • Require will produce a fatal error if the file cannot be found
      • Include will just ignore a missing script file
      • require(‘my.php’);
      • include(‘my.php’);
      • The files can contain PHP and/or HTML
  • 26. Arrays
    • Creating an array
      • $a = array(1,2,3,4,5);
    • Accessing array elements
      • $v = $a[2];
      • $a[2] = 5;
      • $a[] = 1; $a[] = 2; $a[] = 3; //appends to array
  • 27. Iterating Over Arrays
      • for ($i=0; $i<count($a); $i++ ) {
      • print ($a[i]);
      • }
      • foreach( $a as $item ) {
      • print( “<p>$item”);
      • }
    Array variable Local variable. Set to next array element each iteration.
  • 28. Other Array Functions
      • $m = max($a); //returns max value in array
      • $m = min($a); //returns min value in array
      • $s = array_sum($a); //returns sum or array values
      • sort($a); //sorts the items in the array. Changes
      • //the array itself
      • Optional second argument is “sort flags” to control the sort.
  • 29. Associative Arrays
    • Arrays containing key/value pairs
      • $s = array( ‘a’=>’alpha’, ‘b’=>’beta’, … );
      • print ( $s[‘b’] );
    • The parameter to the left of => is the key.
    • The right parameter is the value.
  • 30. SQL – Structured Query Language
    • A language for accessing relational databases
    • Relational databases have tables
    • Tables have fields and contain rows of data
  • 31. SQL Syntax – SELECT
    • Used for retrieving data from a database
      • SELECT [fields] FROM [tables] WHERE [expr]
      • Examples
      • select * from users
      • select abc, def from mytable where ghi=5
  • 32. SQL Syntax – INSERT
    • Used to insert new data in a table
      • INSERT INTO [table] [field names] VALUES [values]
      • Examples
      • insert into users (abc,def,ghi) values (‘111’,22,’cc)
      • insert into xyz values (1,2,3,4,5)
  • 33. SQL Syntax – UPDATE
    • Updating one or more values in existing rows in a table
      • UPDATE [table] SET [name=value pairs] WHERE [expression]
      • Examples
      • update mytable set a=‘aaa’, b=55 where c=11
  • 34. PHP and MySQL Database
    • 5 steps
      • Connect to the Mysql DBMS
      • Pick a database
      • Execute an SQL statement
      • If the SQL was a ‘select’, retrieve the data
      • Close the connection
  • 35. Connecting to MySQL DBMS
      • $con = mysql_connect( /* 3 arguments */ );
      • Your MySQL DBMS server process network location
      • Your MySQL user ID
      • Your MySQL user password
      • For tonight only,
      • mysql_connect(‘www.freesql.org’,’upeworkshop’,’upeworkshop’);
  • 36. Selecting a Database
      • mysql_select_db( ‘upeworkshop’ );
  • 37. Executing an SQL Statement
      • mysql_query( /*SQL statement*/ );
      • Proper form for any SQL not a Select
      • if ( !mysql_query ( “update a ….” ); ) {
      • echo mysql_error(); //for easy debugging, not for final user-oriented website
      • } //returns true/false if it worked, or not
  • 38. For Select SQL Statements
      • $r = mysql_query( ‘select * from abc’ );
      • while ( $row = mysql_fetch_row( $r ) ) { … }
      • $row contains a row of data
      • returns false when no more rows available
      • Iterating through the fields in the row
      • foreach ( $row as $item ) { … }
      • OR access the fields using index position (zero indexed)
      • OR put results in an associative array – less error prone
      • while ($row = mysql_fetch_assoc($r)){
      • echo $row[‘firstname’];
      • }
  • 39. Closing a Connection
      • mysql_close( $con );
  • 40. What is other than core PHP ?
  • 41. What is CMS?
    • A content management system is software that keeps track of every piece of content on your Web site, much like your local public library keeps track of books and stores them.
    • Content can be simple text, photos, music, video, documents, or just about anything you can think of.
  • 42. Famous CMS
  • 43. Joomla
    • Joomla is an free and open source content management system (CMS), which enables you to build Web sites and powerful online applications.
    • Extensible
    • Written in PHP
    • It uses OOP techniques
    • Based on MVC framework.
  • 44. Real world examples
    • Corporate Web sites or portals
    • Online magazines, newspapers, and publications
    • E-commerce and online reservations
    • Government applications
    • Small business Web sites
    • Non-profit and organizational Web sites
    • Community-based portals
  • 45. Servers
    • WAMP
    • LAMP
    • MAMP
    • XAMPP
  • 46. Source
    • HTML/CSS/JS : http://www.w3schools.com
    • PHP : http://www.php.net
    • MySQL : http://www.mysql.com
    • Server : http://www.wampserver.com
    • Joomla : http://www.joomla.org/
  • 47.