Sample Code for Group Assignment2
Sample Code for Group Assignment2
OBJECTIVE:
i. Introduction to Databases with PHP
DB Connection
<?php <?php
$host = 'localhost'; mysqli_close($link);
$user = ‘root'; ?>
$password = '';
$db = ‘lab';
$link = mysqli_connect($host, $user,
$password, $db);
?>
Data Query
/*Select Query*/
<?php
$email = ‘[email protected]‘;
$sql = 'SELECT * FROM user WHERE user_email='.$email; $result = mysqli_query($link,
$sql) or die(mysqli_error());
?>
/* Data Fetch*/
<?php
$noOfData = mysqli_num_rows($result);
while($row = mysqli_fetch_row($result)){
print_r($row);
}
?>
/* Insert Query*/
• <?php
$user_name = ‘Tanzilur Rahman’;
$user_email = ‘[email protected]’;
$password = md5(‘123456’);
date_default_timezone_set('Asia/Dhaka');
$currentTime = date('Y-m-d H:i:s');
*/PHP Session*/
<?php
session_start();
?>
*/PHP Cookies*/
<?php
$cookie_name = "user";
$cookie_value = "John Doe";
setcookie("TestCookie", $value, time()+3600);
?>
*/PHP Redirect*/
<?php
header('Location: http://www.aust.edu/'); die;
?>
Final Project Requirement: You must include following page/ content to your final project.
• Home Page
• About Us Page
• Contact Page
• Login & Registration Option
• User Profile Page
• All Service/All Product Page
• Service/Product Details Page