Добавлено к сравнению
добавлено в избранное
Язык

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Bookings - <?php echo SITE_NAME; ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <?php include 'navbar.php'; ?>

-- Database: car_rental CREATE DATABASE car_rental; USE car_rental;

if ($_SERVER['REQUEST_METHOD'] == 'POST') $username = mysqli_real_escape_string($conn, $_POST['username']); $email = mysqli_real_escape_string($conn, $_POST['email']); $password = password_hash($_POST['password'], PASSWORD_DEFAULT); $full_name = mysqli_real_escape_string($conn, $_POST['full_name']); $phone = mysqli_real_escape_string($conn, $_POST['phone']); $license_number = mysqli_real_escape_string($conn, $_POST['license_number']);

<div class="container mt-4"> <h2>My Bookings</h2> <?php if(mysqli_num_rows($result) > 0): ?> <div class="table-responsive"> <table class="table table-bordered table-hover"> <thead class="table-dark"> <tr> <th>Booking ID</th> <th>Car</th> <th>License Plate</th> <th>Pickup Date</th> <th>Return Date</th> <th>Total Days</th> <th>Total Price</th> <th>Status</th> <th>Payment Status</th> <th>Action</th> </tr> </thead> <tbody> <?php while($booking = mysqli_fetch_assoc($result)): ?> <tr> <td>#<?php echo $booking['id']; ?></td> <td><?php echo $booking['brand'] . ' ' . $booking['model']; ?></td> <td><?php echo $booking['license_plate']; ?></td> <td><?php echo date('d M Y', strtotime($booking['pickup_date'])); ?></td> <td><?php echo date('d M Y', strtotime($booking['return_date'])); ?></td> <td><?php echo $booking['total_days']; ?></td> <td>$<?php echo number_format($booking['total_price'], 2); ?></td> <td> <span class="badge bg-<?php echo $booking['status'] == 'confirmed' ? 'success' : ($booking['status'] == 'pending' ? 'warning' : ($booking['status'] == 'cancelled' ? 'danger' : 'info')); ?>"> <?php echo ucfirst($booking['status']); ?> </span> </td> <td> <span class="badge bg-<?php echo $booking['payment_status'] == 'paid' ? 'success' : 'warning'; ?>"> <?php echo ucfirst($booking['payment_status']); ?> </span> </td> <td> <?php if($booking['status'] == 'pending' && $booking['payment_status'] == 'pending'): ?> <a href="payment.php?booking_id=<?php echo $booking['id']; ?>" class="btn btn-sm btn-primary">Pay Now</a> <a href="cancel-booking.php?id=<?php echo $booking['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">Cancel</a> <?php endif; ?> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> <?php else: ?> <div class="alert alert-info">No bookings found.</div> <?php endif; ?> </div> </body> </html> <?php session_start(); session_destroy(); header("Location: index.php"); exit(); ?> This complete car rental system includes:

// Set timezone date_default_timezone_set('Asia/Kolkata');

<form method="POST" action=""> <div class="mb-3"> <label>Username or Email</label> <input type="text" name="username" class="form-control" required> </div> <div class="mb-3"> <label>Password</label> <input type="password" name="password" class="form-control" required> </div> <button type="submit" class="btn btn-primary w-100">Login</button> </form> <div class="mt-3 text-center"> <a href="register.php">Don't have an account? Register</a> </div> </div> </div> </div> </div> </div> </body> </html> <?php require_once 'config.php'; // Get available cars $sql = "SELECT * FROM cars WHERE status = 'available' ORDER BY brand, model"; $result = mysqli_query($conn, $sql); ?>

<div class="alert alert-info"> <strong>Price per day:</strong> $<?php echo number_format($car['price_per_day'], 2); ?> </div> <form method="POST" action=""> <div class="mb-3"> <label>Pickup Date</label> <input type="date" name="pickup_date" class="form-control" min="<?php echo date('Y-m-d'); ?>" required> </div> <div class="mb-3"> <label>Return Date</label> <input type="date" name="return_date" class="form-control" min="<?php echo date('Y-m-d', strtotime('+1 day')); ?>" required> </div> <button type="submit" class="btn btn-primary w-100">Proceed to Payment</button> </form> </div> </div> </div> </div> </div> </body> </html> <?php require_once 'config.php'; if (!isLoggedIn()) redirect('login.php');

-- Users table CREATE TABLE users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) UNIQUE NOT NULL, email VARCHAR(100) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, full_name VARCHAR(100), phone VARCHAR(20), address TEXT, license_number VARCHAR(50), role ENUM('admin', 'customer') DEFAULT 'customer', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

$error = ''; $success = '';

Введите ключевое слово
Введите ключевое слово
Категории каталога

Car Rental Php Script (2024)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Bookings - <?php echo SITE_NAME; ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <?php include 'navbar.php'; ?>

-- Database: car_rental CREATE DATABASE car_rental; USE car_rental;

if ($_SERVER['REQUEST_METHOD'] == 'POST') $username = mysqli_real_escape_string($conn, $_POST['username']); $email = mysqli_real_escape_string($conn, $_POST['email']); $password = password_hash($_POST['password'], PASSWORD_DEFAULT); $full_name = mysqli_real_escape_string($conn, $_POST['full_name']); $phone = mysqli_real_escape_string($conn, $_POST['phone']); $license_number = mysqli_real_escape_string($conn, $_POST['license_number']); car rental php script

<div class="container mt-4"> <h2>My Bookings</h2> <?php if(mysqli_num_rows($result) > 0): ?> <div class="table-responsive"> <table class="table table-bordered table-hover"> <thead class="table-dark"> <tr> <th>Booking ID</th> <th>Car</th> <th>License Plate</th> <th>Pickup Date</th> <th>Return Date</th> <th>Total Days</th> <th>Total Price</th> <th>Status</th> <th>Payment Status</th> <th>Action</th> </tr> </thead> <tbody> <?php while($booking = mysqli_fetch_assoc($result)): ?> <tr> <td>#<?php echo $booking['id']; ?></td> <td><?php echo $booking['brand'] . ' ' . $booking['model']; ?></td> <td><?php echo $booking['license_plate']; ?></td> <td><?php echo date('d M Y', strtotime($booking['pickup_date'])); ?></td> <td><?php echo date('d M Y', strtotime($booking['return_date'])); ?></td> <td><?php echo $booking['total_days']; ?></td> <td>$<?php echo number_format($booking['total_price'], 2); ?></td> <td> <span class="badge bg-<?php echo $booking['status'] == 'confirmed' ? 'success' : ($booking['status'] == 'pending' ? 'warning' : ($booking['status'] == 'cancelled' ? 'danger' : 'info')); ?>"> <?php echo ucfirst($booking['status']); ?> </span> </td> <td> <span class="badge bg-<?php echo $booking['payment_status'] == 'paid' ? 'success' : 'warning'; ?>"> <?php echo ucfirst($booking['payment_status']); ?> </span> </td> <td> <?php if($booking['status'] == 'pending' && $booking['payment_status'] == 'pending'): ?> <a href="payment.php?booking_id=<?php echo $booking['id']; ?>" class="btn btn-sm btn-primary">Pay Now</a> <a href="cancel-booking.php?id=<?php echo $booking['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">Cancel</a> <?php endif; ?> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> <?php else: ?> <div class="alert alert-info">No bookings found.</div> <?php endif; ?> </div> </body> </html> <?php session_start(); session_destroy(); header("Location: index.php"); exit(); ?> This complete car rental system includes:

// Set timezone date_default_timezone_set('Asia/Kolkata'); 'success' : ($booking['status'] == 'pending'

<form method="POST" action=""> <div class="mb-3"> <label>Username or Email</label> <input type="text" name="username" class="form-control" required> </div> <div class="mb-3"> <label>Password</label> <input type="password" name="password" class="form-control" required> </div> <button type="submit" class="btn btn-primary w-100">Login</button> </form> <div class="mt-3 text-center"> <a href="register.php">Don't have an account? Register</a> </div> </div> </div> </div> </div> </div> </body> </html> <?php require_once 'config.php'; // Get available cars $sql = "SELECT * FROM cars WHERE status = 'available' ORDER BY brand, model"; $result = mysqli_query($conn, $sql); ?>

<div class="alert alert-info"> <strong>Price per day:</strong> $<?php echo number_format($car['price_per_day'], 2); ?> </div> <form method="POST" action=""> <div class="mb-3"> <label>Pickup Date</label> <input type="date" name="pickup_date" class="form-control" min="<?php echo date('Y-m-d'); ?>" required> </div> <div class="mb-3"> <label>Return Date</label> <input type="date" name="return_date" class="form-control" min="<?php echo date('Y-m-d', strtotime('+1 day')); ?>" required> </div> <button type="submit" class="btn btn-primary w-100">Proceed to Payment</button> </form> </div> </div> </div> </div> </div> </body> </html> <?php require_once 'config.php'; if (!isLoggedIn()) redirect('login.php'); 'success' : 'warning';

-- Users table CREATE TABLE users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) UNIQUE NOT NULL, email VARCHAR(100) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, full_name VARCHAR(100), phone VARCHAR(20), address TEXT, license_number VARCHAR(50), role ENUM('admin', 'customer') DEFAULT 'customer', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

$error = ''; $success = '';