1 / 38

CIS166AE : PHP Web Scripting

CIS166AE : PHP Web Scripting. Rob Loy. Tonight’s Agenda. Housekeeping items PHP basics Student connection to server In-class work. Class Logistics. Dates: Sept 5 to Dec 12 Time: Wednesday 6:00 - 9:50pm (Lab time included in class time) Room: CM 447 Section: 36721. Class Structure.

deepak
Download Presentation

CIS166AE : PHP Web Scripting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS166AE : PHP Web Scripting Rob Loy

  2. Tonight’s Agenda • Housekeeping items • PHP basics • Student connection to server • In-class work

  3. Class Logistics • Dates: Sept 5 to Dec 12 • Time: Wednesday 6:00 - 9:50pm(Lab time included in class time) • Room: CM 447 • Section: 36721

  4. Class Structure • Review of homework and lab • Any quizzes or presentations • Lecture/new materials • In-class (hands on) work • Lab work

  5. Class Contact • Web Content: http://www.robloy.com/php • Email1: rob.loy@scc.maricopa.edu • Email2: rob.loy@gmail.com • Phone: 602-418-4041 Send email to BOTH emails for faster response

  6. Class Tools • Eclipse with PHP • Filezilla • Internet Explorer • Phpmyadmin (SQL) • mySCC • SCC Class Folders “CIS-166/”

  7. Student Expectations • Understand basic HTML • Do not need to know programming logic • All assignments will be attempted even if not completed to get a “C” • Some assignments will require work OUTSIDE the class room

  8. Expected Knowledge • Basic HTML Code • Right+click menus • Shortcuts (Copy/Paste etc.) • Folder structures

  9. Class Standards • Lower-case, alphanumeric filenames • Homework submitted by 6:00pm next class • All links emailed to working page on the site • New folder created each week • Lab time is optional, but lab assignment MUST be completed

  10. Semester Agenda • PHP Basics • PHP Functions • PHP Object Orientated Programming (OOP) • PHP/mySQL Databases • PHP Module Creation • PHP Applications

  11. Open Source Environment • L INUX: Operating system for server • A pache: Web server for server • M ySQL: DB application for server • P HP: programming language • XXAMP: Windows complete Apache, PHP and mySQL environment

  12. PHP Environment • Filename extensions has to be .php • Requests from the user goes to an Apache Web Server • Server processes all programming and returns HTML to client (browser) • Any storage is usually in a database on the server side

  13. PHP Basics • Environment • Variable • Constants • Arrays • Code branching • Loops

  14. PHP Functions • PHP Built-in functions • User created functions • Parameters • Scope

  15. PHP OOP • Object Oriented Programming (OOP) • Class creation • Object creation • OOP Methods

  16. PHP/mySQL DB • Databases 101 • phpmyadmin • SQL SELECT • SQL INSERT • SQL UPDATE

  17. User Created Modules • Web contact page • Newsletter sign-up • Secured pages • Image gallery • Facebook application • Mobile application (web service)

  18. PHP Applications • WordPress • OSCommerce • Drupal • Any other PHP applications?

  19. Student Connection • Domain: http://<domainname>.com • FTP URL: <domainname>.com • Username: springscc<number> • Password: <given in class> • Directory: <domainname> • mySQL Admin: mysql.<domainname>.com

  20. Domains for Class

  21. PHP Coding Terms • Whitespace does not impact results • { } = braces / curlies • () = parenthesis • ; = semicolon • \ = back slash • / = forward clash

  22. PHP Operators - Math • + - Addition • - - Subtraction • * - Multiplication • / - Division • % - Modulus (division remainder) • ++ - Incement + 1 • -- - Decrement – 1 • . - String addition (e.g 1.1 = 11) http://www.w3schools/php/php_operators.asp

  23. PHP Operators - Comparison • < - Less than • > - Greater than • <> - Not equal • == - Equals • ! - NOT (e.g. !== means NOT equal) http://www.w3schools/php/php_operators.asp

  24. Basic PHP Code Syntax • <?php ?>: contains PHP code for the server to translate • //: php comments • echo $a;: prints the item or variable to the screen • print($a);: prints the item or variable to the screen • All statements end with a semicolon

  25. PHP Variables • Variables are represented by a dollar sign followed by the name of the variable. • Not tied to a specific type of variable like Java, .NET. • A variable name can only contain alpha-numeric characters and underscores • Variable name is case-sensitive. • Examples: $cost, $obj_name • Syntax: $cost = 4.12, $obj_name = “bike” http://www.w3schools/php/php_variables.asp

  26. PHP Arrays • Variable capable of holding more than one value in a single reference variable • Content held in a Key / Value config • Examples: $month[] • Syntax set-up: $month = array(“Jan”,”Feb”,“Mar”,“Apr”); • Syntax look-up:echo $month[2]; $month = array(“Jan”,”Feb”,“Mar”,“Apr”); http://php.net/manual/en/language.types.array.php

  27. PHP Constants • A constant cannot change value • A constant is case-sensitive by default • Constant identifiers are uppercase • Examples: COST, UNIT_TAX • Syntax: DEFINE (COST, 4.12)DEFINE (OBJ_NAME, “My bicycle”); http://php.net/manual/en/language.constants.php

  28. PHP & HTML (1) <?php $a = “John”; ?> <html> <body> <p>Hello <?php echo $john; ?></p> </body> </html>

  29. PHP & HTML (2) <?php $a = “John”; echo “<html>\n”; echo “<body> echo “<p>Hello “ . $john . “</p>\n”; echo “</body>\n”; echo “</html>\n”; ?>

  30. IMPORTANT NOTE • Eclipse is part of MySCC • Filezilla is part of MySCC • You can NOT use MySCC Filezilla in class • For each class, download Filezilla and install on the desktop!

  31. In Class Work

  32. FTP (Filezilla) • Connect to remote server using credentials • Click files and then click: • GET file FROM remote server • PUT files ON to remote server • Drag files to move files • Can also RIGHT CLICK to see more options

  33. Editing (Notepad) • Open Notepad • Save file as index.php • You can use any text editor

  34. HTML Form Syntax • Form method: How the information goes. • GET = in the URL string • POST = in HTTP Header (preferred) • Form action: Where the information goes. • Input name: How the information is stored (“variable” name)

  35. PHP & HTML Forms <form method=“POST” action=“form.php”> <input type=“text” name=“fred”> <input type=“submit”> </form> form.html <?php echo “<p>Name is “.$_POST[“fred”].“</p>\n”; ?> form.php

  36. Previewing Work • Use any browser • Navigate to the URL and the folder/file name(reminder case-sensitive) • Might have to click F5 to refresh pages • Check HTML -> View Source

  37. Next Week • Programming basic • User Functions • PHP Functions • Eclipse (IDE)

  38. Homework/Lab • 1) Send me an email with your domain name you picked in class • 2) Send me an email with the link to the work we did in class in a folder called “homework1”. The homework should be accessible at the following URL: http://<domainname>.com/homework1/index.php

More Related