Database Connectivity in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Murach's MySQL, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
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.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Individual Bidder Enrollment
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
NAVY Research Group Department of Computer Science Faculty of Electrical Engineering and Computer Science VŠB-TUO 17. listopadu Ostrava-Poruba.
Objectives Connect to MySQL from PHP
Validating user input Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Website Development Working with MySQL. What you will achieve today! Connecting to mySql Creating tables in mySql Saving data on a server using mySql.
File uploading in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Tables in HTML Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
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,
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
INTERNET APPLICATION DEVELOPMENT For More visit:
Page Layout Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
Concepts of Database Management Seventh Edition
Creating Databases with MySQL Workbench Build the Forums database in Ullman’s Chapter 6.
 Mysql – popular open-source database management system  PHP usually works with Mysql for web- based database applications  LAMP applications—Web-based.
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
PHP meets MySQL.
Adding Image, audio and video files to web pages Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
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. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
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.
Database and mySQL Week 07 Dynamic Web TCNJ Jean Chu.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Modeling web applications
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.
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.
Retrieving data from MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
HTML FORMS Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 1.
© 2007 by Prentice Hall2-1 Introduction to Oracle 10g Chapter 2 Overview of SQL and SQL*Plus James Perry and Gerald Post.
HTML 5 Form elements Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
HTML Links and navigation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
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,
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
The Web Wizard’s Guide to PHP by David Lash
Chapter 5 Introduction to SQL.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.
Web Design and Development
Web Design and Development
© 2012, Mike Murach & Associates, Inc.
Passing variables between pages
Test Automation For Web-Based Applications
Presentation transcript:

Database Connectivity in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1

Summary of the previous lecture Writing regular expression in PHP Validating user’s input String functions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 2

Outline Creating database in MySQL using WAMP Connecting PHP with MySQL Inserting data in database CONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 3

1. Creating database in MySQL using WAMP Go to home page of WAMP server Select PHP myadmin Login to MySql Enter database name and click create database button Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 4

1. Creating database in MySQL using WAMP… Creating a table in a database: Select database from the list of databases Enter table name and number of columns Enter name, data-type and other required properties for columns Click create table button Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 5

2. Connecting PHP with MySQL mysql_connect(“hostname”,”username”, ”password”) – mysql_connect(“localhost”,”root”,””) mysql_select_db(“database name”) – mysql_select_db(“testdatabase”) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 6

2. Connecting PHP with MySQL… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 7 Connect with server Host name username Empty passwordError message Select databaseDatabase name

3. Inserting data in database Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 8 Create form to receive input from user On action page – Retrieve user’s input – Validate user’s input (optional) – Establish connection with database – Write insert command – Execute command

3. Inserting data in database… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 9 Insert SQL command: INSERT INTO `table_name` (list of columns) VALUES (list of values) INSERT INTO users (‘user_Name’,’user_ ’,’user_Password’) VALUES (‘$name’,’$ ’,’$password’) mysql_query(query to execute)

3. Inserting data in database… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 10 post reg_action.php for later use name password

3. Inserting data in database… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 11 User’s input is retrieved Database connection Insert command Command is executed

3. Inserting data in database… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 12 Header function location message Close warnings Message is displayed

3. Inserting data in database… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 13 message

4. CONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 14 Create database – Database name: connections – Table name: users Table columns: – user_Id int 4 – User_Name text 25 – User_ varchar 35 – User_Password varchar 20 – User_Picture varchar 50

4. CONNECTIONS: user registration… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 15 name password post

4. CONNECTIONS: user registration… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 16 Connection to the server Database selection Database name

4. CONNECTIONS: user registration… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 17 User’s input is retrieved Database connection Name validation

4. CONNECTIONS: user registration… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 18 validation Insert command Command is executed

Summary Creating database in MySQL using WAMP Connecting PHP with MySQL Inserting data in database CONNECTIONS: user registration Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 19

References Chapter 30, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 20