1Computer Sciences Department Princess Nourah bint Abdulrahman University.

Slides:



Advertisements
Similar presentations
PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Slide 1 of 40 PHP Form Handling The PHP superglobals $_GET and $_POST are used to collect form-data. EX: Name: CENG 449 Lecture 11.
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.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
IS1500: Introduction to Web Development
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Advance web Programming Chapter 3: MySQL Date: 28 April 2014 Advance web Programming Chapter 3: MySQL Date: 28 April 2014 Dr. Mogeeb A. A. Mosleh .
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
PHP Forms and User Input The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
INTERNET APPLICATION DEVELOPMENT For More visit:
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
PHP MySQL Introduction
Week 7. Lecture 3 PHP Forms. PHP forms In part 2 of this course, we discussed html forms, php form is similar. Lets do a quick recap of the things we.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Slide 1 of 40 PHP Form Handling The PHP superglobals $_GET and $_POST are used to collect form-data. EX: Name: CENG 449 Lecture 11.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
Website Development with PHP and MySQL Saving Data.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
CSC 2720 Building Web Applications Server-side Scripting with PHP.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Global Variables - Superglobals Several predefined variables in PHP are "superglobals", which means that they are always accessible, regardless of scope.
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Part 2 Lecture 9 PHP Superglobals and Form Handling.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP: MySQL. PHP Connect to MySQL PHP 5 and later can work with a MySQL database using: – MySQLi extension (the "i" stands for improved) – PDO (PHP Data.
CHAPTER 10 PHP MySQL Database
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
MySQL MySQL and PHP – interacting with a database.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
PHP – Hypertext Preprocessor.
PHP: MySQL Lecture 14 Kanida Sinmai
CHAPTER 5 SERVER SIDE SCRIPTING
Introduction to Dynamic Web Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Design and Development
Introduction to Web programming
PHP + MySQL Commands Refresher.
PHP FORM HANDLING Post Method
Introduction to Web programming
PHP and Forms.
Tutorial 6 PHP & MySQL Li Xu
PHP Forms and Databases.
PHP-II.
Introduction to Web programming
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Presentation transcript:

1Computer Sciences Department Princess Nourah bint Abdulrahman University

And use

PHP Part 3

 Creating a new MySQL Database using………  Create & Check connection with Database that has been created.  Creating a new table  Form Handling  GET vs. POST methods  Insert, select, delete, update data Objectives Computer Sciences Department4

5 Creating a new MySQL Database

 After WAMP server has started, you will see the WAMP icon as shown below in the notification area at the bottom-right side of the desktop.  If the icon is green as shown above, all services like Apache, MySQL etc. are running. If the icon is not green, left-click on it. You will see the WAMP administrator panel as shown below. Click on “Start All Services”. Computer Sciences Department6 Step 1

 Click on “phpMyAdmin” under the “Tools” section. Log in with Username and Password for MySQL. Generally, the Username is "root" with no Password required for the Super user of MySQL Computer Sciences Department7 Step 2

Computer Sciences Department8 Step 3 “create a new Database” Note: Don't use a dot( “.”) in the database name

Computer Sciences Department9 Step 4 “create a new Table”

Computer Sciences Department10 Step 5 “Create new field”

 Insert, delete, or modify ……etc. date Computer Sciences Department11 Step 6

Computer Sciences Department12 Create a form “example”

 When the user fills out the form …….and clicks the submit button, the form data is sent for processing to a PHP file named “?????????.php".  The form data is sent with the HTTP POST method. Computer Sciences Department13 PHP 5 Form Handling

  ID:  Name:  Date:  Computer Sciences Department14 Step 7 “create a form”

 Both GET and POST create an array (e.g. array( key => value, key2 => value2, key3 => value3,...)). This array holds key/value pairs, where keys are the names of the form controls and values are the input data from the user.  $_GET is an array of variables passed to the current script via the URL parameters.  $_POST is an array of variables passed to the current script via the HTTP POST method Computer Sciences Department15 GET vs. POST

 Information sent from a form with the GET method is visible to everyone (all variable names and values are displayed in the URL). GET also has limits on the amount of information to send. The limitation is about 2000 characters. However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases.  GET may be used for sending non-sensitive data.  Note: GET should NEVER be used for sending passwords or other sensitive information! Computer Sciences Department16 When to use GET?

 $user = 'root';  $pass = '';  $db = 'db_test';  $hostname = 'localhost';  // Create connection  $con=mysqli_connect($hostname,$user, $pass, $db);  // Check connection  if (mysqli_connect_errno())  {  echo "Failed to connect to DataBase: ". mysqli_connect_error();  } Computer Sciences Department17 Step 8 “Create & Check connection with Database”

 Information sent from a form with the POST method is invisible to others (all names/values are embedded within the body of the HTTP request) and has no limits on the amount of information to send.  Moreover POST supports advanced functionality such as support for multi-part binary input while uploading files to server.  However, because the variables are not displayed in the URL, it is not possible to bookmark the page. Computer Sciences Department18 When to use POST?

 Explanation Explanation Computer Sciences Department19 PHP 5 Form Validation

 When some fields cannot be empty and must be filled out in the HTML form.  if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); }  Example Example Computer Sciences Department20 PHP 5 Forms - Required Fields

Computer Sciences Department21 Insert, select, delete, update data

Computer Sciences Department22

Computer Sciences Department23

 The SELECT statement is used to select data from one or more tables  SELECT column_name(s) FROM table_name  or we can use the * character to select ALL columns from a table:  SELECT * FROM table_name Computer Sciences Department24 PHP Select Data From MySQL

Computer Sciences Department25

 The DELETE statement is used to delete records from a table  DELETE FROM table_name WHERE some_column = some_value Computer Sciences Department26 PHP Delete Data From MySQL

Computer Sciences Department27

 The UPDATE statement is used to update existing records in a table  UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Computer Sciences Department28 PHP Update Data in MySQL

Computer Sciences Department29