NMD202 Web Scripting Week3. What we will cover today Assignment 1 Email Database Concepts MySQL Exercises Server side validation Exercises.

Slides:



Advertisements
Similar presentations
Keys, Referential Integrity and PHP One to Many on the Web.
Advertisements

2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
PHP (2) – Functions, Arrays, Databases, and sessions.
INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Pro Exchange SPAM Filter An Exchange 2000 based spam filtering solution.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Database Lecture # 1 By Ubaid Ullah.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Web Application Development. Tools to create a simple web- editable database QSEE MySQL (or PHPMyAdmin) PHP TableEditor.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Database Technical Session By: Prof. Adarsh Patel.
Information Systems Today (©2006 Prentice Hall) MySQL 1CS3754 Class Note #8, Is an open-source relational database management system 2.Is fast and.
PHP meets MySQL.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Security Considerations Steve Perry
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
CHAPTER 10 PHP MySQL 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.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
MIDTERM REVIEW IST 210 Organization of Data IST210 1.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
Databases.
Introduction to Dynamic Web Programming
CS320 Web and Internet Programming SQL and MySQL
Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.
CIS 336 str Competitive Success/snaptutorial.com
CIS 336 Competitive Success/snaptutorial.com
CIS 336 str Education for Service- -snaptutorial.com.
CIS 336 Education for Service-- snaptutorial.com.
CIS 336 Teaching Effectively-- snaptutorial.com
CIS 336 str Teaching Effectively-- snaptutorial.com.
ISC440: Web Programming 2 Server-side Scripting PHP 3
CS1222 Using Relational Databases and SQL
Teaching slides Chapter 8.
Chapter 7 Using SQL in Applications
Tutorial 6 PHP & MySQL Li Xu
CS3220 Web and Internet Programming SQL and MySQL
CS3220 Web and Internet Programming SQL and MySQL
DATABASE Purpose of database
Presentation transcript:

NMD202 Web Scripting Week3

What we will cover today Assignment 1 Database Concepts MySQL Exercises Server side validation Exercises

Assignment 1 Milestone 1 – due week 5 Project Brief – What do you pretend to do Data Model – ER Diagram must be submitted in a VISIO file

Assignment 1 Examples of what you can do: Budget tracker Mini-Blog Address Book Event Planner 3 tables at least

PHP Can connect to a mail transfer agent to send s. Mail settings are configured in the php.ini file. linux mail can be used (ie:postfix or sendmail) or you can use SMTP (platform independent)

Send mail: mail function: mail ($to,$subject,$message); This is the basic usage of mail, often you need to set headers as well.

Setting Headers: <?php $to = $subject = 'the subject'; $message = 'hello'; $headers = 'From: "\r\n". 'Reply-To: "\r\n". 'X-Mailer: PHP/'. phpversion(); mail($to, $subject, $message, $headers); ?>

Multiple lines in the message: <?php $message = “ Hello \n\r This is another line \n\r This is the third line \n\r ”; ?>

It is also possible to send html <?php $message = “ Hello ”; $headers = 'Content-type: text/html; charset=iso '. "\r\n"; ?> Check

PHP mail function is cumbersome, the php community has developed better solutions: LibMail HTML Mime Mail

PHP mail function is cumbersome, the php community has developed better solutions: LibMail HTML Mime mail Allow: Send multiple attachments, receipts, etc...

Security Considerations: Sanitize user inputs before sending mail: Header injection Multiple recipient injection Avoid using mail function unless you know what you are doing

Some applications tag s sent from php as Spam if headers are not properly setup, ie:Yahoo, Google. If you targeting clients that use these s you need to tweak the headers.

Database Concepts A Database is a structured collection of data Usually databases are relational: The basic data structure of the relational model is a table where information about a particular entity (say, an employee) is represented in columns and rows columns enumerate the various attributes of an entity They obey to strict rules such as: a table cannot contain 2 identical rows.

Database Concepts

Anomalies: logical or structural problems in the data model Database normalization: Fixing anomalies, Normal forms (1nf, 2nf, 3nf)

Database Concepts

Exercise: Normalize the following Table: Student Subject Name Subject Description Ass 1 Grade Ass 2 Grade Exam Grade Luis Maths1Initial Maths12 Luis Maths1Initial Maths14 Peter m Web Script PHP, javascript 15 Peter m Maths111215

MySQL Relational Database System – Query language ANSI SQL 99 Different type of tables: ISAM, InnoDB, etc. ISAM – fast, but does not enforce referential integrity. (default) InnoBD – enforces referential integrity, only available in MySQL v4+

MySQL Commands: show databases; - display all available databases use #database; - sets the current database show tables;-display all tables from current database describe #table;-display table information create... – create table drop...- delete table/database alter #table... – update a table structure Insert into... – inserts data into a table update #table set... – update data from a table Select... from #table where... – query database

MySQL Create Statement: CREATE DATABASE sampleDatabase; USE sampleDatabase; CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT );

MySQL Create Statement: CREATE DATABASE sampleDatabase; USE sampleDatabase; CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT );

MySQL Insert Statement: INSERT INTO example (name,age) VALUES (‘Luis’,12); INSERT INTO example (name,age) VALUES (‘Peter’,13); INSERT INTO example (name,age) VALUES (‘John’,26); INSERT INTO example (name,age) VALUES (‘Kim’,78); INSERT INTO example (name,age) VALUES (‘Peter’,45);

MySQL Query Database: SELECT name,age FROM example; Or SELECT * FROM example WHERE name=‘Peter’;

MySQL Update Database: UPDATE example SET name=‘Ryan’, age = 35 WHERE id=2;

MySQL Using MySQL: Start MySQL Server From the command prompt go to: C:\temp\xampp\mysql\bin Start the client: mysql –u root

MySQL Keep your commands in scite in case you need to redo them. (it is easy to drop a table and start again instead of using the ALTER statement). Make sure all commands are terminated with a semicolon ‘;’

MySQL After you finished either keep your scite file with all your commands or do an sql dump of your work, run from the dos prompt (inside mysql bin folder) mysqldump --databases [databasename] -u root >[backupfile.sql] In our example: mysqldump --databases sampleDatabase -u root > backup.sql

MySQL To Restore the database: mysql -u root < [backupfile.sql] In our example: mysql -u root < back.sql

Exercise: Create the data model that you normalized in your previous exercise Insert some more records into the tables (students, subjects and grades) Update all Luis grades to 100 Delete all peter records Backup your database, send me the dump by