0% found this document useful (0 votes)
11 views

Unit 10 - Website Design & Development: Lesson (12) - PHP Part Ii

This document covers PHP form handling and interacting with a MySQL database. It discusses using the $_GET and $_POST superglobals to collect form data. It explains that developers prefer POST for sending form data. It also shows how to connect to a MySQL database in PHP and how to insert, update, delete, and search data using MySQLi functions. The INSERT statement is used to add records, the UPDATE statement updates existing records where a condition is met, and DELETE removes records based on a WHERE clause.

Uploaded by

Harry potter
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Unit 10 - Website Design & Development: Lesson (12) - PHP Part Ii

This document covers PHP form handling and interacting with a MySQL database. It discusses using the $_GET and $_POST superglobals to collect form data. It explains that developers prefer POST for sending form data. It also shows how to connect to a MySQL database in PHP and how to insert, update, delete, and search data using MySQLi functions. The INSERT statement is used to add records, the UPDATE statement updates existing records where a condition is met, and DELETE removes records based on a WHERE clause.

Uploaded by

Harry potter
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Unit 10 –Website Design & Development

Lesson [12] – PHP Part II

1
PHP Form Handling

The PHP superglobals $_GET and $_POST are used to collect form-data.

2
PHP Form Handling

3
PHP Form Handling

4
GET vs. POST

Both GET and POST are treated as $_GET and $_POST.


$_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.

Developers prefer POST for sending form data.

5
PHP Connect to MySQL

Before access data in the MySQL database, need to be


able to connect to the server

6
Insert Data Into MySQL Using MySQLi

After a database and a table have been created, we can start adding data in them.
 The INSERT INTO statement is used to add new records to a MySQL table:
 INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

7
Insert Data Into MySQL Using MySQLi

8
Update Data Using MySQLi

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
Notice the WHERE clause in the UPDATE syntax: The WHERE clause specifies which
record or records that should be updated. If you omit the WHERE clause, all records will be
updated!

9
Update Data Using MySQLi

10
Delete Data Using MySQLi

The DELETE statement is used to delete records from a table:


DELETE FROM table_name
WHERE some_column = some_value
Notice the WHERE clause in the DELETE syntax: The WHERE clause specifies which
record or records that should be deleted. If you omit the WHERE clause, all records will be
deleted!

11
Delete Data Using MySQLi

12
Search Data Using MySQLi

The SELECT statement is used to search 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

13
Search Data Using MySQLi

14
The End..!!

15

You might also like