Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Introduction The concept of “SQL Injection”
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
PHP (2) – Functions, Arrays, Databases, and sessions.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved.
PHP and MySQL. Why Use a Database  Easy access to data  Simultaneous access by multiple users is handled properly  Security - easy to control access.
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Python MySQL Database Access
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
PHP with MySQL 1.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
An Introduction to Designing and Executing Workflows with Taverna Aleksandra Pawlik materials by: Katy Wolstencroft University of Manchester.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
PHP PDO & PHP SOAP Introduce. Agenda What is PHP PDO and PHP SOAP? Setup PHP PDO to connect database, query database and close the connection. Setup SOAP.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Security Considerations Steve Perry
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
WEB SECURITY WEEK 2 Computer Security Group University of Texas at Dallas.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Form Handling IDIA 618 Fall 2014 Bridget M. Blodgett.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
MySQL MySQL and PHP – interacting with a database.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Unix System Administration
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
ISC440: Web Programming 2 Server-side Scripting PHP 3
Developing a Model-View-Controller Component for Joomla Part 3
PHP.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
Introduction to Web programming
Presentation transcript:

Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45

PHP Data Object (PDO) PDO is the currently preferred way to access a database The object can be configured to connect to several different database types, allowing you to learn one set of functions for multiple databases

PDO Connection $db = new PDO($connectionString, $username, $password) $connectionString: mysql:host= :123;dbname=database; Once the object is created, you can invoke several methods to invoke SQL queries

PDO Basic Select $query = $db->query(“SELECT * FROM table”); This creates a query object, but does not actually run the query $results = $query->fetch(…);//return next row ->fetchAll(…);//return all rows Inside of the fetch command, we want to specify how the data should be returned PDO::FETCH_ASSOC PDO::FETCH_NUM PDO::FETCH_BOTH

PDO Basic Select Often times when using fetch(), we will use a while loop while($row = $query->fetch(PDO::FETCH_ASSOC)) And we may end the while loop early, meaning we don’t actually retrieve all the rows, saving some processing time If we need to know the number of results, or know we need to get everything, we can use fetchAll() foreach($query->fetchAll(PDO::FETCH_ASSOC) AS $key => $val)

PDO Security Using the query method can be a simple way to get your query executed, but if you are using any data the user provided to build your query, there is a chance of SQL Injection To avoid this, we use the prepare() method, with bindParam() methods The bindParam() method will ensure that the data you are adding to the query is properly sanitized before the SQL is executed

PDO Prepare The prepare() method is also helpful in building an object that contains a query we want to run multiple times, for instance, when inserting several rows at a time $select = $db->prepare(“SELECT * FROM table WHERE ID = ?”); $select->bindParam(1, $id); $id = 5; $select->execute(); $results = $select->fetchAll();

PDO Prepare $select = $db->prepare(“SELECT * FROM table WHERE ID = :id”); $select->bindParam(“:id”, $id); $id = 5; $select->execute(); $results = $select->fetchAll(); $id = 6; $select->execute(); $results = $select->fetchAll();

PDO Insert Insert/Update/Delete commands are all executed the same way as the select examples we did, using query() or prepare() There are a few additional methods that are helpful to us with these items: $db->lastInsertId(); $db->errorCode(); $db->errorInfo(); $update->rowCount();//doesn’t work with select queries errorCode and errorInfo can also be run off of prepare() objects

PDO Practice Select rows from a table Insert a new row into a table Update an existing row with new data Delete an existing row

Lab 3 - PHP Due: Sept 24 th Create a PHP page with a simple web form Include at least: Two text fields ( ) One drop down ( ) One radio button group with at least two radio buttons ( //same name attribute will cause them to group together) A submit button

Lab 3 - PHP Set up PHP code to validate that all fields had values entered Create styled error messages if fields were not completed (for example, red text saying which field was not completed) Output the values entered on the page

Lab 4 - MySQL Due: Oct 1 Create a simple web form Create a MySQL DB and Table to store the submissions from the form Set up the PHP code to write the submissions to the table Use PHP to create a table below the form with all of the data currently in the table (when new data is submitted to the form, another table row should appear with that data)

Next Time Model, View, Controller (MVC) using CodeIgniter We will be working with this topic for two weeks CodeIgniter is a PHP framework, so we will be spending the next two weeks working with more PHP and MySQL