23 November 2015 Scheiden van HTML en PHP emplatePower.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.
Specially made for you Wat te doen in het leven What To Do In Life Be Calm Wees Kalm.
Copyright met toestemming gebruikt van Stichting Licentie © 1997 Hillsongs Australia 1/6 CHURCH ON FIRE (Russel Fragar) 1 The Holy Spirit is here and His.
Adverbs of Frequency (Bijwoorden van tijd).  Een “adverb of frequency” geeft aan hoe vaak iets gebeurd.  Always, usually, never, often, sometimes, occasionally,
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag functie definitions;.h files;
CHAPTER 3 MORE ON FORM HANDLING INCLUDING MULTIPLE FILES WRITING FUNCTIONS.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Lesson 6. Today’s lesson Homework Top 5s Grammar: past perfect & future perfect Bonus Assignment Linking words Vocabulary.
Web Database Programming Connecting Database to Web.
Everyday Italian Giada De Laurentiis Harry Potter J K. Rowling Learning XML Erik T. Ray CSCI 305 Introduction to Database.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
PHP –Writing Reusable Code 10 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
Wordpress Hoe doe je dat bij DSE Bloggen met. Log in op de homepage, klik in mijn account op Wordpress installeren.
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
INTERNET APPLICATION DEVELOPMENT For More visit:
Internet and Web Application Development Revision.
Create an online booking system (login/registration)
Homework for October 2011 Nikolay Kostov Telerik Corporation
PHP – MySQL Extensions. Table used in most examples CREATE TABLE product ( rowID INT NOT NULL AUTO_INCREMENT, productid VARCHAR(8) NOT NULL, name VARCHAR(25)
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
JavaScript Lecture 6 Rachel A Ober
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Includes and Dates.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
SHOPPING CARTS CHAPTER 19. E-COMMERCE Typically, an e-commerce site will have public pages and admin pages.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Assignment help PHP + MySQL crash course Minpeng Zhu.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Lecture 10 – MYSQL and PHP (Part 2)
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
Chapter 6: Authentications. Training Course, CS, NCTU 2 Overview  Getting Username and Password  Verifying Username and Password  Keeping The Verification.
PHP with MySQL 1.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Intro to PHP Carl-Erik Svensson. What is PHP? PHP is a widely-used general-purpose scripting language that is especially suited for Web development and.
Sessions in PHP – Page 1 of 13CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Sessions in PHP Reading: Williams.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
PHP-based Authentication
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
Chapter 1 Introduction to PHP Part 1. Textbook’s Code DOWNLOADS PHP and MySQL for Dynamic Web Sites Complete Set of Scripts.
PHP with MYSQL Please use speaker notes for additional information!
OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,
PHP Overview. What is PHP Widely available scripting language Free Alternative to Microsoft’s ASP Runs on the Web Server; not in the browser Example:
CGS 3066: Web Programming and Design Spring 2016 PHP.
NU BURGERSCHAP 3/4 Project online 2Reclame: daar trap jij toch niet in? Voeg hier je commercial in: Invoegen > Video > Onlinevideo. Lukt dat niet? Geef.
PHP WORKSHOP (Session 1) INFO 257 Supplement. Outline What is PHP ? PHP Language Basics PHP Exercise.
Paragraaf 3.2: De energie van de toekomst. 1 Herhaling vorige les 2 Energietransitie 3 Duurzaam en zuinige energie 4 Maken opdrachten 5 (Werken aan je.
Motivatie & Commitment – Een eerste stap naar slagen voor je examen statistiek
PHP (Session 1) INFO 257 Supplement.
Introduction to PHP Part 1
>> PHP: Form Processing
Wordorder: Place and Time.
Assignment help PHP + MySQL crash course
Assignment help PHP + MySQL crash course
In Class Programming BIS1523 – Lecture 11.
PHP: Combo box FdSc Module 109 Server side scripting and
Muziek : Sjeng is oan de geng Gezongen door “de nachtroave”
SWEET MERCIES (David Ruis)
PHP: Database connection
Assignment help PHP + MySQL crash course
Presentation transcript:

23 November 2015 Scheiden van HTML en PHP emplatePower

templatePower Hoe halen we PHP en HTML uit elkaar Templates hebben één heel mooi doel, namelijk om PHP en HTML te scheiden. Zonder templates komt het vaak voor dat je een heel groot script hebt gemaakt, met HTML ertussen en dat je achteraf iets wil aanpassen aan het uiterlijk.

Staat los van aanroepende php-script

templatePower (wat is niet goed?)

templatePower (FORMS) form.tpl The following errors occurred. - {message}

templatePower (FORMS) myscript.php <?php include_once('./class.TemplatePower.inc.php'); $tpl = new TemplatePower('form.tpl'); $tpl->prepare(); $errorMessage = Array(); $errorFound = false; if( isset( $_POST[‘submit’] ) ) { if ( !isset($_POST[‘ ’]) ) { $errorMessage[] = 'No address entered'; $errorFound = true; } if( $errorFound ) { $tpl->newBlock('error'); $size = sizeof($errorMessage); for( $i=0; $i < $size; $i++ ) { $tpl->newBlock('message'); $tpl->assign('message', $errorMessage[$i]); } } else { Header('Location: member.php'); } } $tpl->printToScreen(); ?>

templatePower (ASSIGNGLOBAL) assignGlobal ( string variablename, mixed value ) assignGlobal ( array( variablename => value ) ) myscript.php <?php include_once( "./class.TemplatePower.inc.php" ); $tpl = new TemplatePower( "./img.tpl" ); $tpl->prepare(); $tpl->assignGlobal( "imagedir", "images"); for ( $i=1; $i<=10; $i++ ) { $tpl->newBlock( "image" ); $tpl->assign( "id", $i ); } $tpl->printToScreen(); ?> img.tpl AssignGlobal Example

templatePower IMAGES

templatePower (ASSIGN) BestandIndex.tpl index Welkom {persoon}! <?php include("class.TemplatePowe r.inc.php"); $tpl = new TemplatePower("index.tpl"); $tpl->prepare(); $tpl->assign("persoon", "XenoX"); $tpl->printToScreen(); ?>

templatePower (ASSIGN(ARRAY)) {titel} Welkom {persoon}! prepare(); $tpl->assign(array( "titel" => "TemplatePower", “persoon" => "XenoX“ ) ); $tpl->printToScreen(); ?>

templatePower (ASSIGNINCLUDE) myscript.php <?php include_once( "./class.TemplatePower.inc.php" ); $tpl = new TemplatePower( "./include.tpl" ); $tpl->assignInclude( "header", "./header.tpl" ); $tpl->assignInclude( "content", "./about.php" ); $tpl->prepare(); $tpl->printToScreen(); ?> include.tpl AssignInclude Example

templatePower (ASSIGNINCLUDE) <?php include( "./class.TemplatePower.inc.php"); //connect to database $link = mysql_connect("host", "user", "passwd") or die("Could not connect"); mysql_select_db("my_database") or die("Could not select database"); //get database templates $qry = "SELECT base, header FROM templates"; $result = mysql_query($qry); if( mysql_num_rows($result) > 0) { list($base, $header) = mysql_fetch_row($result); } //make a new TemplatePower object $tpl = new TemplatePower( $base, T_BYVAR ); //assign include template by variable $tpl->assignInclude( "header", $header, T_BYVAR ); $tpl->prepare(); //print the result $tpl->printToScreen(); ?>

templatePower (GETVARVALUE) number.tpl AssignInclude Example {number} {total} myscript.php <?php include_once( "./class.TemplatePower.inc.php" ); $tpl = new TemplatePower( "./number.tpl" ); $tpl->prepare(); for( $i=1; $i <= 10; $i++ ) { $tpl->newBlock( "number" ); $tpl->assign( "number", $i ); $tpl->assign( "_ROOT.total", ($tpl->getVarValue( "_ROOT.total" ) + $i) ); } $tpl->printToScreen(); ?>

templatePower (GOTOBLOCK) newBlock.tpl NewBlock Names {name} {total_names} myscript.php <?php include_once( "./class.TemplatePower.inc.php" ); $tpl = new TemplatePower( "./newBlock.tpl" ); $tpl->prepare(); $count = 0; while( $count < 10 ) { $tpl->newBlock( "name_row" ); $tpl->assign( "name", "Ron" ); $count++; } $tpl->gotoBlock( "_ROOT" ); $tpl->assign( "total_names", $count ); $tpl->printToScreen(); ?>

templatePower (BLOCK) {titel} Welkom {persoon}! {id} : {naam}

templatePower (BLOCK) prepare(); $tpl->assign(array("titel" => "TemplatePower", "persoon" => "XenoX“ )); $tpl->newBlock("rij"); $tpl->assign(array("id" => "1", "naam" => "Joël“ )); $tpl->newBlock("rij"); $tpl->assign(array("id" => "11", "naam" => "FangorN“ )); $tpl->printToScreen(); ?>

templatePower (BLOCK-NESTED) prepare(); $tpl->assign(array("titel" => "TemplatePower", "persoon" => "XenoX“ )); $tpl->newBlock("rij"); $tpl->assign(array("id" => "25", "naam" => "XenoX“ )); $tpl->newBlock("blockinblock"); $tpl->printToScreen(); ?>

templatePower (OUTPUT VAR) prepare(); $tpl->assign(array("titel" => "TemplatePower“, "persoon" => "XenoX“ )); $template = $tpl->getOutputContent(); ?>

templatePower (FORMS) form.tpl The following errors occurred. - {message}

templatePower (FORMS) myscript.php <?php include_once('./class.TemplatePower.inc.php'); $tpl = new TemplatePower('form.tpl'); $tpl->prepare(); $errorMessage = Array(); $errorFound = false; if( isset( $submit ) ) { if($ == '') { $errorMessage[] = 'No adress entered'; $errorFound = true; } if( $errorFound ) { $tpl->newBlock('error'); $size = sizeof($errorMessage); for( $i=0; $i < $size; $i++ ) { $tpl->newBlock('message'); $tpl->assign('message', $errorMessage[$i]); } } else { Header('Location: member.php'); } } $tpl->printToScreen(); ?>