Файл: Разработка сайта интернет-магазина фильмов «FilmStore».pdf
Добавлен: 23.04.2023
Просмотров: 158
Скачиваний: 1
if ( !isset($_SESSION['cart_list'])) {
$_SESSION['cart_list'][] = $current_added_card;
}
$films_check = false;
if ( isset($_SESSION['cart_list']) ) {
foreach ($_SESSION['cart_list'] as $value) {
if ( $value['id'] == $current_added_card['id'] ) {
$films_check = true;
}
}
}
if ( !$films_check ) {
$_SESSION['cart_list'][] = $current_added_card;
}
} else {
header("Location: 404.php");
}
}
// var_dump($_SESSION);
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>FilmStore</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
</head>
<style>
.card {
width: 500px;
height: 300px;
float: left;
margin: 35px 20px;
margin-left: 25%;
margin-top: 10%;
margin-bottom: 27%;
padding: 10px;
padding-top: 10px;
}
.card a {
width: 150px;
margin-right: 3%;
}
</style>
<body>
<?php require "header.php" ?>
<div class="container">
<div class="row">
<div class="card">
<div class="card-body">
<h1>Корзина</h1>
<?php if ( isset($_SESSION['cart_list']) && count($_SESSION['cart_list']) !=0 ) : ?>
<ul>
<?php foreach( $_SESSION['cart_list'] as $card ) : ?>
<li>
<?php echo $card['title']; ?> |
<?php echo $card['price']; ?> руб. |
<a href="cart.php?delete_id=<?php echo $card['id'];?>">Удалить</a>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<p>
Ваша корзина пуста
</p>
<?php endif; ?>
<a class="btn btn-outline-secondary" href="index.php">Продолжить покупки</a>
<a class="btn btn-outline-secondary" href="order.php">Оформить заказ</a>
</div>
</div>
</div>
</div>
<?php require "footer.php" ?>
</body>
</html>
Страница формы «Регистрация» reg.php
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>FilmStore</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
</head>
<style>
.card {
width: 850px;
height: 500px;
float: left;
margin: 35px 20px;
margin-left: 10%;
margin-top: 9%;
margin-bottom: 14.6%;
padding: 10px;
padding-top: 10px;
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="/">FilmStore</a>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Главная
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">О нас</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Связаться с нами</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="card">
<div class="card-body">
<form class="box" action="check.php" method="post">
<h2>Регистрация</h2><br>
<input type="text" class="form-control" name="name" id="name" placeholder="Введите имя"><br>
<input type="text" class="form-control" name="login" id="login" placeholder="Введите логин"><br>
<input type="password" class="form-control" name="password" id="password" placeholder="Введите пароль"><br>
<button class="btn btn-outline-secondary" type="submit">Зарегистрироваться</button><br><br>
<p>Либо</p> <a class="btn btn-outline-secondary" href="auth.php">Авторизоваться</a>
</form>
</div>
</div>
</div>
</div>
<?php require "footer.php" ?>
</body>
</html>
Страница формы «Авторизация» auht.php
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>FilmStore</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
</head>
<style>
.card {
width: 650px;
height: 500px;
float: left;
margin: 35px 20px;
margin-left: 25%;
margin-top: 9%;
margin-bottom: 14.6%;
padding: 10px;
padding-top: 10px;
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="/">FilmStore</a>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Главная
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">О нас</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Связаться с нами</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="card">
<div class="card-body">
<form class="box" action="checkauth.php" method="post">
<h2>Авторизация</h2><br>
<input type="text" class="form-control" name="login" id="login" placeholder="Введите логин"><br>
<input type="password" class="form-control" name="password" id="password" placeholder="Введите пароль"><br>
<button class="btn btn-outline-secondary" type="submit">Авторизоваться</button><br><br>
<p>Еще не зарегистрированы?</p> <a class="btn btn-outline-secondary" href="reg.php">Зарегистрируйтесь!</a>
</form>
</div>
</div>
</div>
</div>
<?php require "footer.php" ?>
</body>
</html>
Страница «Профиль» profile.php
<?php
session_start();
require_once "db.php";
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<title>Film store</title>
</head>
<style>
.container2 {
width: 900px;
height: 600px;
border: 1px solid #000;
margin: 0 auto;
margin-top: 80px;
margin-bottom: 90px;
border-radius: 1%;
border-color: #dcdde1;
}
.left_block {
width: 350px;
height: 600px;
border: 1px solid #000;
margin-right: 40%;
border-radius: 2%;
border-color: #dcdde1;
}
h3 {
padding-left: 20%;
}
.left_block button {
margin-left: 20%;
cursor: pointer;
padding-left: 10%;
padding-right: 10%;
}
.left_block button[name = Баланс] {
padding-left: 11%;
padding-right: 11%;
}
.left_block button[name = Избранное] {
padding-left: 12%;
padding-right: 12%;
}
.left_block button[name = Желания] {
padding-left: 14.5%;
padding-right: 14.5%;
}
.left_block button[name = Настройки] {
padding-left: 12.5%;
padding-right: 12.5%;
}
.row {
width: 350px;
margin-left: -0.5%;
border-radius: 5%;
padding-top: 2%;
padding-bottom: 4%;
}
.right_block {
width: 500px;
height: 600px;
margin-left: 44.5%;
margin-top: -67%;
border-radius: 2%;
}
h4 {
text-align: center;
font-size: 2em;
}
.row2 {
padding: 2% 0 2% 0;
}
img {
margin-top: 6%;
margin-left: 5%;
border-radius: 50%;
}
button {
margin-left: 7%;
}
.box {
width: 200px;
height: 300px;
margin-left: 50%;
margin-top: -50%;
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="/">FilmStore</a>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Главная
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">О нас</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Связаться с нами</a>
</li>
<li class="nav-item">
<a class="nav-link" href="cart.php">Корзина
<span id="cart_count">
<?php
if (isset ($_SESSION['cart_list'])) {
echo count($_SESSION['cart_list']);
} ?>
</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="exit.php">Выйти</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container2">
<div class="left_block">
<div class="row">
<h3>Меню профиля</h3>
</div><br><br>
<button class="btn btn-outline-secondary" name="Мои фильмы">Мои фильмы</button><br><br>
<button class="btn btn-outline-secondary" name="Баланс">Мой баланс</button><br><br>
<button class="btn btn-outline-secondary" name="Избранное">Избранное</button><br><br>
<button class="btn btn-outline-secondary" name="Желания">Желания</button><br><br>
<button class="btn btn-outline-secondary" name="Настройки">Настройки</button>
</div>
<div class="right_block">
<div class="row2">
<h4>Мой профиль</h4>
</div>
<img src="img/logo.jpg" width="150" height="200"><br><br>
<button class="btn btn-outline-secondary">Редактировать</button>
<div class="box">
Профиль пока что пустой
</div>
</div>
</div>
<?php require "footer.php" ?>
</body>
</html>
Страница «подробного описания» фильма single.php
<?php
session_start();
//if (isset($_SESSION['cart_list'])) {
// echo "КОРЗИНА: " . count($_SESSION['cart_list']) . " шт";
//}
require_once "db.php";
if ( isset($_GET['id']) ) {
$query = "SELECT * FROM films WHERE id=" . $_GET['id'];
$req = mysqli_query($connection, $query);
$current_card = mysqli_fetch_assoc($req);
// var_dump($current_film);
if (empty($current_card)) {
header("Location: 404.php");
}
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>FilmStore</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
</head>
<style>
.card {
width: 1100px;
height: auto;
float: left;
margin: 35px 20px;
margin-left: 10%;
padding: 10px ;
padding-top: 10px;
}
</style>
<body>
<?php require "header.php" ?>
<div class="container">
<div class="row">
<div class="card">
<div class="card-body">
<h1>
<?php echo $current_card['title']?>
</h1>
<p>
<?php echo $current_card['decsription']?>
</p>
<p><strong>
<?php echo $current_card['price']?> руб
</strong></p>
<?php
if($_COOKIE['user'] == ''): ?>
<?php else: ?>
<a class="btn btn-outline-secondary" href="order.php?title=<?php echo $current_card['title']?>">Купить в 1 клик</a><br><br>
<a class="btn btn-outline-secondary" href="cart.php?card_id=<?php echo $current_card['id']?>">Добавить в корзину</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php require "footer.php" ?>
</body>
</html>
Страница «Заказ» order.php
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>FilmStore</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/shop-homepage.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
</head>
<style>
.card {
width: 500px;
height: auto;
float: left;
margin: 35px 20px;
margin-left: 25%;
margin-top: 15%;
margin-bottom: 23.9%;
padding: 10px;
padding-top: 10px;
}
</style>
<body>
<?php require "header.php" ?>
<div class="container">
<div class="row">
<div class="card">
<div class="card-body">
<h1>Заказ</h1>
<form>
<?php if ( isset($_GET['title']) ) : ?>
<p>Вы заказываете фильм: <?php echo $_GET['title']; ?></p>
<?php elseif ( isset($_SESSION['cart_list']) ) : ?>
<ul>
<?php foreach( $_SESSION['cart_list'] as $card ) : ?>
<li><?php echo $card['title']; ?> | <?php echo $card['price']; ?> руб.</li>
<?php endforeach; ?>
</ul>
<p>
<a class="btn btn-outline-secondary" href="cart.php">Изменить заказ</a>
</p>
<?php endif; ?>
<form class="contact_form" action="#" method="post" name="contact_form">
<input type="text" class="form-control" name="name" id="name" placeholder="Введите имя"><br>
<input type="email" class="form-control" name="email" id="email" placeholder="Введите почту"><br>