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

PHP Output 11 & 12

The document discusses DDL and DML operations using SQL queries. It shows how to create a database and table, insert, update, and delete data from the table. It also provides an example of user authentication using PHP by creating a users table to store login credentials and allows users to register and login.

Uploaded by

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

PHP Output 11 & 12

The document discusses DDL and DML operations using SQL queries. It shows how to create a database and table, insert, update, and delete data from the table. It also provides an example of user authentication using PHP by creating a users table to store login credentials and allows users to register and login.

Uploaded by

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

Program – 11 - DDL/DML operations.

Coding

CREATE DATABASE college111;


USE college111; -- Changed from 'college' to 'college11'
-- Create Admissions Table
CREATE TABLE Admissions (
admission_id INT PRIMARY KEY AUTO_INCREMENT,
full_name VARCHAR(100),
date_of_birth DATE,
gender ENUM('Male', 'Female', 'Other'),
address VARCHAR(255),
email VARCHAR(100),
phone_number VARCHAR(15),
course_name VARCHAR(100),
fees DECIMAL(10,2)
);
INSERT INTO Admissions (full_name, date_of_birth, gender, address, email,
phone_number, course_name, fees) VALUES ('Jagathish Kumar', '2004-07-11', 'Male',
'K.G.Chavadi', '[email protected]', '8778864924', 'BCA', 20000.00);

Output
1. DDL (Data Definition Language):
1. CREATE 2. ALTER 3. DROP
ALTER (coding)
ALTER TABLE Admissions
ADD COLUMN admission_date DATE;

2. DML (Data Manipulation Language):

1. SELECT 2. INSERT 3. UPDATE 4. DELETE

UPDATE (coding)
UPDATE Admissions
SET fees = 25000.00
WHERE full_name = 'Jagathish Kumar';

DELETE
DELETE FROM AdmissionsWHERE full_name = 'Jagathish Kumar';
Program – 11 - DDL/DML operations.

Coding

SQL QUERY

CREATE TABLE users (

id INT PRIMARY KEY AUTO_INCREMENT,

username VARCHAR(255) NOT NULL,

password VARCHAR(255) NOT NULL

);

<?php

$db = new mysqli('localhost', 'root', '', 'authentication');

if (isset($_POST['create'])) {

$db->query("INSERT INTO users (username, password) VALUES ('$_POST[username]',


'$_POST[password]')");

echo "User created successfully";

if (isset($_POST['login'])) {

$result = $db->query("SELECT * FROM users WHERE username='$_POST[username]'


AND password='$_POST[password]'");

if ($result->num_rows > 0) {

header('Location: welcome.php');

} else {

echo "Invalid username or password";

?>
<form method="post" action="">

Username: <input type="text" name="username">

Password: <input type="password" name="password">

<input type="submit" name="create" value="Create">

</form>

<form method="post" action="">

Username: <input type="text" name="username">

Password: <input type="password" name="password">

<input type="submit" name="login" value="Login">

</form>

Output

You might also like