Gate
Gate
php
<?php
// Retrieve the form data
$username = $_POST['username'];
$password = $_POST['password'];
// Prepare the SQL statement to insert the user into the table
$sql = "INSERT INTO users (username, password) VALUES ('$username',
'$password')";
addUser.html
<!DOCTYPE html>
<html>
<head>
<title>User Management</title>
<style>
/* CSS styles */
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
h2 {
color: #333;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
font-weight: bold;
}
button {
padding: 8px 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<!-- Add User Form -->
<h2>Add User</h2>
<form id="add-user-form" action="add_user.php" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</tbody>
</table>
<script src="script.js"></script>
</body>
</html>
Admin.html
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
padding: 20px;
background-image: url('image/visitor.jpg');
background-size: cover;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
background-color: #cc582e;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 10px;
}
nav ul li a {
text-decoration: none;
color: #130997;
padding: 5px;
}
nav ul li a:hover {
background-color: #2d0daf;
}
h1 {
text-align: center;
color: rgb(30, 31, 30);
}
p {
text-align: center;
color: rgb(5, 5, 5);
}
footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #1d55cf;
padding: 10px 0;
text-align: center;
color: white;
}
.content {
max-width: 50%;
margin: 0 auto;
background-color: rgba(164, 85, 37, 0.8);
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.image-container {
display: flex;
justify-content: center;
margin-top: 20px;
}
.image-container img {
width: 200px;
height: 200px;
object-fit: cover;
border-radius: 50%;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#">HOME</a></li>
<li><a href="details.html">REGISTER</a></li>
<li><a href="total_card.php">vCARDS</a></li>
<li><a href="visitor_stutus.php">VSTATUS</a></li>
<li><a href="visitors_total.php">REPORT</a></li>
<div class="content">
<h1>ARDHI UNIVERSITY VISITORS RECORD</h1>
<p>WELCOME VISITOR</p>
</div>
</div>
</div>
<footer>
© SR12.
</footer>
<script>
// JavaScript code to show and hide the additional information
document.addEventListener('DOMContentLoaded', function() {
const aboutUsLink = document.getElementById('aboutUsLink');
const additionalInfo = document.getElementById('additionalInfo');
aboutUsLink.addEventListener('click', function(e) {
e.preventDefault();
additionalInfo.classList.toggle('hidden');
});
});
</script>
</body>
</html>
adminPage.html
<!DOCTYPE html>
<html>
<head>
<title>Admin Dashboard</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
padding: 20px;
background-image: url('image/admin.jpg');
background-size: cover;
}
h1 {
color: blue;
text-align: center;
}
.dashboard {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
margin-top: 40px;
}
.card {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.card h2 {
color: blue;
margin-bottom: 10px;
}
.card p {
margin: 0;
}
</style>
</head>
<body>
<h1>Welcome, Admin</h1>
<div class="dashboard">
<a href="report.php" class="card">
<h2>Total Visitors</h2>
</a>
<a href="adduser.html" class="card">
<h2>USERS</h2>
</a>
<a href="visitors_total.php" class="card">
<h2>REPORT</h2>
</a>
</a>
<a href="visitor_stutus.php" class="card">
<h2>VSTATUS</h2>
</a>
</div>
</body>
</html>
Busser.php
<!DOCTYPE html>
<html>
<head>
<title>Welcome Page</title>
</head>
<style>
/* CSS styles */
body {
background-color: yellow;
font-family: Arial, sans-serif;
}
h1 {
color: green;
}
</style>
<body>
<h1>VISITOR STATUS</h1>
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Check if the form is submitted for filling out the checkout time
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$visitorId = $_POST['visitor-id'];
$timeOut = $_POST['time-out'];
// Prepare an SQL statement to update the checkout time for the visitor
$sql = "UPDATE visitors SET time_out = ? WHERE id = ?";
$stmt = $connection->prepare($sql);
// Extract the date and time from the check-in datetime value
$checkInDate = date('Y-m-d', strtotime($checkInDateTime));
$checkInTime = date('H:i:s', strtotime($checkInDateTime));
echo "<br><br>";
}
} else {
echo "No visitor records found.";
}
</body>
</html>
Checkout.php
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Prepare an SQL statement to update the checkout time for the visitor
$sql = "UPDATE visitors SET time_out = ? WHERE id = ?";
$stmt = $connection->prepare($sql);
Delete_user.php
<?php
// Retrieve the user ID from the query parameter
$userId = $_GET['id'];
// Prepare the SQL statement to delete the user from the table
$sql = "DELETE FROM users WHERE id = $userId";
Details.html
<!DOCTYPE html>
<html>
<head>
<title>Enter Visitor Details</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
background-image: url("image/id.jpg");
background-size: cover;
background-position: center;
}
h1 {
color: blue;
text-align: center;
font-family: Arial, sans-serif;
}
form {
background-color: #fff;
padding: 9px;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
max-width: 300px;
margin: 0 auto;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"],
input[type="time"],
textarea,
select {
width: 100%;
padding: 4px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 6px;
}
input[type="submit"],
input[type="button"] {
background-color: yellow;
color: blue;
padding: 4px 8px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover,
input[type="button"]:hover {
background-color: green;
}
.horizontal-line {
border-top: 1px solid #ccc;
margin: 8px 0;
}
</style>
<script>
// JavaScript code
var visitorNumbers = {
busser: 0,
masijala: 0,
dup: 0,
dean: 0
};
function updateVisitorNumber() {
var officeSelect = document.getElementById("office");
var visitorNumberInput = document.getElementById("visitor-number");
var selectedOption = officeSelect.value;
if (selectedOption) {
visitorNumbers[selectedOption]++;
visitorNumberInput.value =
selectedOption.charAt(0).toUpperCase() + visitorNumbers[selectedOption];
} else {
visitorNumberInput.value = "";
}
}
window.onload = function() {
var dateTimeNow = new Date().toISOString().slice(0, 16);
var timeInInput = document.getElementById("time-in");
timeInInput.value = dateTimeNow;
};
</script>
</head>
<body>
<h1>ENTER VISITOR DETAILS</h1>
<label for="address">Address:</label>
<textarea id="address" name="address" required></textarea>
<div class="horizontal-line"></div>
Get_users.php
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$database = 'myapp';
Index.php
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: orange;
}
h1 {
text-align: center;
color: pupple;
}
form {
max-width: 300px;
margin: 0 auto;
padding: 20px;
background-color: blue;
color: white;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 15px;
}
select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 15px;
}
input[type="submit"] {
background-color: yellow;
color: blue;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: green;
}
</style>
</head>
<body>
<h1>Login</h1>
<form action="login.php" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
Login.php
<?php
session_start();
// Get the username, password, and user type from the login form
$username = $_POST['username'];
$password = $_POST['password'];
$userType = $_POST['user-type'];
Receipt.php
<!DOCTYPE html>
<html>
<head>
<title>VISITOR CARD</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
.receipt-container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
max-width: 300px;
margin: 0 auto;
}
.receipt-item {
margin-bottom: 10px;
}
.receipt-label {
font-weight: bold;
display: block;
}
.receipt-value {
margin-top: 5px;
}
.action-buttons {
text-align: center;
margin-top: 20px;
}
.action-buttons button {
padding: 10px 20px;
background-color: yellow;
color: blue;
border: none;
border-radius: 4px;
margin-right: 10px;
}
.action-buttons button.cancel {
background-color: #ccc;
color: #333;
}
</style>
</head>
<body>
<div class="receipt-container">
<h1>VISITOR CARD</h1>
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Prepare an SQL statement to retrieve the most recent form data from
the database
$sql = "SELECT * FROM visitors ORDER BY id DESC LIMIT 1";
$result = $connection->query($sql);
<div class="receipt-item">
<span class="receipt-label">Phone:</span>
<span class="receipt-value"><?php echo $row['phone']; ?></span>
</div>
<div class="receipt-item">
<span class="receipt-label">Office:</span>
<span class="receipt-value"><?php echo $row['office']; ?></span>
</div>
<div class="receipt-item">
<span class="receipt-label">Visitor Number:</span>
<span class="receipt-value"><?php echo $row['visitor_number']; ?
></span>
</div>
<div class="receipt-item">
<span class="receipt-label">Address:</span>
<span class="receipt-value"><?php echo $row['address']; ?
></span>
</div>
<div class="receipt-item">
<span class="receipt-label">Time In:</span>
<span class="receipt-value"><?php echo $row['time_in']; ?
></span>
</div>
<div class="action-buttons">
<button onclick="window.print()">Print Card</button>
<button class="cancel"
onclick="window.location.href='admin.html'">Cancel</button>
</div>
Report.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myapp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Visitors List</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
h1 {
color: blue; /* Change title color to blue */
text-align: center; /* Center align the heading */
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
</style>
<script>
function exitVisitor(visitorId) {
// Send an AJAX request to update the visitor's exit time in the
database
var xhr = new XMLHttpRequest();
xhr.open('POST', 'update_exit.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-
urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
location.reload(); // Refresh the page after successful
update
}
};
xhr.send('visitorId=' + visitorId);
}
</script>
</head>
<body>
<h1>Visitors List</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Phone Number</th>
<th>Office Number</th>
<th>Visitor Number</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<?php foreach ($visitors as $visitor): ?>
<tr>
<td><?php echo $visitor["id"]; ?></td>
<td><?php echo $visitor["first_name"]; ?></td>
<td><?php echo $visitor["last_name"]; ?></td>
<td><?php echo $visitor["phone"]; ?></td>
<td><?php echo $visitor["office"]; ?></td>
<td><?php echo $visitor["visitor_number"]; ?></td>
<td><?php echo $visitor["address"]; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
Save.php
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Prepare an SQL statement to insert the form data into the database
$sql = "INSERT INTO visitors (first_name, last_name, phone, office,
visitor_number, address, time_in) VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt = $connection->prepare($sql);
Scripts.js
// Fetch the user list from the server and populate the table
function fetchUserList() {
var userListContainer = document.getElementById('user-list');
var tbody = userListContainer.querySelector('tbody');
tbody.innerHTML = ''; // Clear existing table rows
total_card.php
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Prepare an SQL statement to retrieve the receipts for the requested date
$sql = "SELECT * FROM visitors WHERE DATE(time_in) = '$requestedDate' ORDER BY
time_in ASC";
$result = $connection->query($sql);
<!DOCTYPE html>
<html>
<head>
<title>View Cards</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
h1 {
color: blue;
text-align: center;
}
.receipts-container {
background-color: #fff;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
max-width: 800px;
margin: 0 auto;
}
.receipt-item {
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
}
.receipt-label {
font-weight: bold;
margin-right: 5px;
}
.action-buttons {
text-align: center;
margin-top: 10px;
}
.action-buttons button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
margin-right: 10px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="receipts-container">
<h1>Cards for <?php echo $requestedDate; ?></h1>
<div>
<span class="receipt-label">Last Name:</span>
<span><?php echo $receipt['last_name']; ?></span>
</div>
<div>
<span class="receipt-label">Phone Number:</span>
<span><?php echo $receipt['phone']; ?></span>
</div>
<div>
<span class="receipt-label">Office Number:</span>
<span><?php echo $receipt['office']; ?></span>
</div>
<div>
<span class="receipt-label">Visitor Number:</span>
<span><?php echo $receipt['visitor_number']; ?></span>
</div>
<div>
<span class="receipt-label">Address:</span>
<span><?php echo $receipt['address']; ?></span>
</div>
<div>
<span class="receipt-label">Time In:</span>
<span><?php echo $receipt['time_in']; ?></span>
</div>
<div class="action-buttons">
<button onclick="window.print()">Print</button>
</div>
</div>
<?php endforeach; ?>
<?php else : ?>
<p>No cards found for <?php echo $requestedDate; ?>.</p>
<?php endif; ?>
</div>
</body>
</html>
Update_exist.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myapp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
// Visitor record found
$visitor = $result->fetch_assoc();
$conn->close();
?>
Validate.php
<?php
include_once('connection.php');
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = test_input($_POST["username"]);
$password = test_input($_POST["password"]);
$stmt = $conn->prepare("SELECT * FROM adminlogin");
$stmt->execute();
$users = $stmt->fetchAll();
foreach($users as $user) {
?>
Visitor_status.php
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Check if the form is submitted for filling out the checkout time
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$visitorId = $_POST['visitor-id'];
$timeOut = $_POST['time-out'];
// Prepare an SQL statement to update the checkout time for the visitor
$sql = "UPDATE visitors SET time_out = ? WHERE id = ?";
$stmt = $connection->prepare($sql);
echo "<tr>";
echo "<td>$name</td>";
echo "<td>$address</td>";
echo "<td>$office</td>";
echo "<td>$checkInTime</td>";
echo "<td>$checkOutTime</td>";
echo "<td>$status</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "No visitor records found.";
}
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
</html>
Visitors_total.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myapp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Visitor Totals</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
h1 {
color: blue; /* Change title color to blue */
text-align: center; /* Center align the heading */
}
table {
width: 50%;
margin: 0 auto;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
<table>
<thead>
<tr>
<th>Office</th>
<th>Total Visitors</th>
</tr>
</thead>
<tbody>
<?php foreach ($totals as $office => $totalVisitors): ?>
<tr>
<td><?php echo $office; ?></td>
<td><?php echo $totalVisitors; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
Buser.php
<!DOCTYPE html>
<html>
<head>
<title>Welcome Page</title>
</head>
<body>
<h1>Welcome to Busser</h1>
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Check if the form is submitted for filling out the checkout time
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$visitorId = $_POST['visitor-id'];
$timeOut = $_POST['time-out'];
// Prepare an SQL statement to update the checkout time for the visitor
$sql = "UPDATE visitors SET time_out = ? WHERE id = ?";
$stmt = $connection->prepare($sql);
echo "<br><br>";
}
} else {
echo "No visitor records found.";
}
</body>
</html>
Connection.php
<?php
$conn = "";
try {
$servername = "localhost:3306";
$dbname = "myapp";
$username = "root";
$password = "";
$conn->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
Delete_user.php
<?php
// Retrieve the user ID from the query parameter
$userId = $_GET['id'];
// Prepare the SQL statement to delete the user from the table
$sql = "DELETE FROM users WHERE id = $userId";
Masijala.php
<!DOCTYPE html>
<html>
<head>
<title>Welcome Page</title>
</head>
<body>
<h1>Welcome to Masijala</h1>
<?php
// Replace the placeholder values with your actual database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'myapp';
// Check if the form is submitted for filling out the checkout time
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$visitorId = $_POST['visitor-id'];
$timeOut = $_POST['time-out'];
// Prepare an SQL statement to update the checkout time for the visitor
$sql = "UPDATE visitors SET time_out = ? WHERE id = ?";
$stmt = $connection->prepare($sql);
echo "<br><br>";
}
} else {
echo "No visitor records found.";
}
</body>
</html>
View.php
<?php
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myapp";
// Prepare the SQL statement to retrieve visitor records for the current day
$sql = "SELECT * FROM visitor WHERE DATE(time_in) = '$currentDate'";
// Check if there are any visitor records for the current day
if ($result->num_rows > 0) {
echo '<h2>Visitor Records for ' . $currentDate . '</h2>';
echo '<table>';
echo '<tr>';
echo '<th>First Name</th>';
echo '<th>Last Name</th>';
echo '<th>Phone Number</th>';
echo '<th>Office</th>';
echo '<th>Address</th>';
echo '<th>Time In</th>';
echo '<th>Time Out</th>';
echo '</tr>';
echo '</table>';
} else {
echo 'No visitor records for ' . $currentDate;
}
```sql
```
```sql
);
```
```sql
visitor_id INT,
first_name VARCHAR(255),
last_name VARCHAR(255),
office VARCHAR(255),
time_in DATETIME,
time_out DATETIME,
visitor_number INT,
);
```
```php
$host = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$database = 'myapp';
```
With:
```php
$host = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$database = 'myapp';
```
**Note:** Make sure to replace the placeholder values with your actual database
credentials.
**Also, ensure that the MySQLi extension is installed and enabled in your PHP
configuration.**
Cart.php
<?php
session_start();
require 'connection.php';
if(!isset($_SESSION['email'])){
header('location: login.php');
}
$user_id=$_SESSION['id'];
$user_products_query="select it.id,it.name,it.price from users_items ut inner
join items it on it.id=ut.item_id where ut.user_id='$user_id'";
$user_products_result=mysqli_query($con,$user_products_query) or
die(mysqli_error($con));
$no_of_user_products= mysqli_num_rows($user_products_result);
$sum=0;
if($no_of_user_products==0){
//echo "Add items to cart first.";
?>
<script>
window.alert("No items in the cart!!");
</script>
<?php
}else{
while($row=mysqli_fetch_array($user_products_result)){
$sum=$sum+$row['price'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/lifestyleStore.png" />
<title>Lifestyle Store</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"
type="text/css">
<!-- jquery library -->
<script type="text/javascript" src="bootstrap/js/jquery-
3.2.1.min.js"></script>
<!-- Latest compiled and minified javascript -->
<script type="text/javascript"
src="bootstrap/js/bootstrap.min.js"></script>
<!-- External CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div>
<?php
require 'header.php';
?>
<br>
<div class="container">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<th>Item Number</th><th>Item
Name</th><th>Price</th><th></th>
</tr>
<?php
$user_products_result=mysqli_query($con,
$user_products_query) or die(mysqli_error($con));
$no_of_user_products=
mysqli_num_rows($user_products_result);
$counter=1;
while($row=mysqli_fetch_array($user_products_result)){
?>
<tr>
<th><?php echo $counter ?></th><th><?php echo
$row['name']?></th><th><?php echo $row['price']?></th>
<th><a href='cart_remove.php?id=<?php echo
$row['id'] ?>'>Remove</a></th>
</tr>
<?php $counter=$counter+1;}?>
<tr>
<th></th><th>Total</th><th>Rs <?php echo $sum;?>/-
</th><th><a href="success.php?id=<?php echo $user_id?>" class="btn btn-
primary">Confirm Order</a></th>
</tr>
</tbody>
</table>
</div>
<br><br><br><br><br><br><br><br><br><br>
<footer class="footer">
<div class="container">
<center>
<p>Copyright © Lifestyle Store. All Rights Reserved. |
Contact Us: +255 717999790</p>
<p>This website is developed by Lucas Samson</p>
</center>
</div>
</footer>
</div>
</body>
</html>
Connection.php
<?php
/
*$con=mysqli_connect("localhost","id2538044_sajalagrawal","******","id2538044_sto
re") or die(mysqli_error($con));*/
$con=mysqli_connect("localhost","root","","store") or die(mysqli_error($con));
?>
Hearder.php
</ul>
</div>
</div>
</nav>
Comfirmation.php
<?php
session_start();
require 'connection.php';
if(!isset($_SESSION['email'])){
header('location:index.php');
}else{
$user_id=$_GET['id'];
$confirm_query="update users_items set status='Confirmed' where
user_id=$user_id";
$confirm_query_result=mysqli_query($con,$confirm_query) or
die(mysqli_error($con));
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/lifestyleStore.png" />
<title>Lifestyle Store</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"
type="text/css">
<!-- jquery library -->
<script type="text/javascript" src="bootstrap/js/jquery-
3.2.1.min.js"></script>
<!-- Latest compiled and minified javascript -->
<script type="text/javascript"
src="bootstrap/js/bootstrap.min.js"></script>
<!-- External CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div>
<?php
require 'header.php';
?>
<br>
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="panel panel-primary">
<div class="panel-heading"></div>
<div class="panel-body">
<p>Your order is confirmed. Thank you for
shopping with us. <a href="products.php">Click here</a> to purchase any other
item.</p>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<center>
<p>Copyright © Lifestyle Store. All Rights Reserved. |
Contact Us: +255 717999790</p>
<p>This website is developed by Lucus Samson</p>
</center>
</div>
</footer>
</div>
</body>
</html>
Products.php
<?php
session_start();
require 'check_if_added.php';
?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/lifestyleStore.png" />
<title>Lifestyle Store</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"
type="text/css">
<!-- jquery library -->
<script type="text/javascript" src="bootstrap/js/jquery-
3.2.1.min.js"></script>
<!-- Latest compiled and minified javascript -->
<script type="text/javascript"
src="bootstrap/js/bootstrap.min.js"></script>
<!-- External CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div>
<?php
require 'header.php';
?>
<div class="container">
<div class="jumbotron">
<h1>Welcome to our LifeStyle Store!</h1>
<p>We have the best suit, Trousers and shirts for you. No
need to hunt around, we have all in one place.</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/shirt.jpg" alt="Cannon">
</a>
<center>
<div class="caption">
<h3>Cannon EOS</h3>
<p>Price: Tsh. 36000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(1)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=1"
class="btn btn-block btn-primary" name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/pink.jpg" alt="Sony DSLR">
</a>
<center>
<div class="caption">
<h3>Sony DSLR</h3>
<p>Price: Tsh. 40000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(2)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=2"
class="btn btn-block btn-primary" name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/HXR.jpg" alt="Sony DSLR">
</a>
<center>
<div class="caption">
<h3>Sony DSLR</h3>
<p>Price: Tsh. 50000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(3)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=3"
class="btn btn-block btn-primary" name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/hmt.jpg" alt="Olympus">
</a>
<center>
<div class="caption">
<h3>Olympus DSLR</h3>
<p>Price: Tsh. 80000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(4)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=4"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/shirt.jpg" alt="Titan 301">
</a>
<center>
<div class="caption">
<h3>Titan Model #301</h3>
<p>Price: Tsh. 130000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(5)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=5"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/sony_dslr.jpg" alt="Titan 201">
</a>
<center>
<div class="caption">
<h3>Titan Model #201</h3>
<p>Price: Tsh. 30000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(6)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=6"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/sony_dslr2.JPG" alt="htm milan">
</a>
<center>
<div class="caption">
<h3>HMT Milan</h3>
<p>Price: Tsh. 80000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(7)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=7"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/raymond.jpg" alt="Favre Leuba">
</a>
<center>
<div class="caption">
<h3>Favre Leuba #111</h3>
<p>Price: Tsh. 18000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(8)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=8"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/shirt.jpg" alt="Raymond shirt">
</a>
<center>
<div class="caption">
<h3>Raymond</h3>
<p>Price: Tsh. 50000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(9)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=9"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/charles.jpg" alt="Charles shirt">
</a>
<center>
<div class="caption">
<h3>Charles</h3>
<p>Price: Tsh. 10000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(10)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=10"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/HXR.jpg" alt="HXR">
</a>
<center>
<div class="caption">
<h3>HXR</h3>
<p>Price: Tsh. 90000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(11)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=11"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<a href="cart.php">
<img src="img/pink.jpg" alt="PINK">
</a>
<center>
<div class="caption">
<h3>PINK</h3>
<p>Price: Tsh. 25000.00</p>
<?php if(!isset($_SESSION['email'])){ ?>
<p><a href="login.php" role="button"
class="btn btn-primary btn-block">Buy Now</a></p>
<?php
}
else{
if(check_if_added_to_cart(12)){
echo '<a href="#" class=btn btn-
block btn-success disabled>Added to cart</a>';
}else{
?>
<a href="cart_add.php?id=12"
class="btn btn-block btn-primary " name="add" value="add" class="btn btn-block
btr-primary">Add to cart</a>
<?php
}
}
?>
</div>
</center>
</div>
</div>
</div>
</div>
<br><br><br><br><br><br><br><br>
<footer class="footer">
<div class="container">
<center>
<p>Copyright © Lifestyle Store. All Rights Reserved. |
Contact Us: +255 717999790</p>
<p>This website is developed by Lucas Samson</p>
</center>
</div>
</footer>
</div>
</body>
</html>
Cart_add.php
<?php
require 'connection.php';
//require 'header.php';
session_start();
$item_id=$_GET['id'];
$user_id=$_SESSION['id'];
$add_to_cart_query="insert into users_items(user_id,item_id,status) values
('$user_id','$item_id','Added to cart')";
$add_to_cart_result=mysqli_query($con,$add_to_cart_query) or
die(mysqli_error($con));
header('location: products.php');
?>