A full-featured car purchasing platform built using PHP, MySQL, HTML, CSS, and JavaScript. Designed for user-friendly browsing, secure purchasing, and smooth database interaction.
- π User Registration & Login with session management
- π Browse cars by brand (Tesla, Toyota, Mazda, etc.)
- π§Ύ Purchase cars with delivery & payment details
- ποΈ Database integration (MySQL) for users, cars & orders
- π± Responsive and mobile-first design
- π¨ Modern and intuitive UI
Cars24/
βββ assets/ # Images and static assets
βββ config/
β βββ database.php # Database configuration
βββ index.html # Main homepage (static version)
βββ index.php # Main homepage (dynamic version)
βββ login.php # User login page
βββ register.php # User registration page
βββ purchase.php # Car purchase form
βββ logout.php # User logout
βββ database.sql # Database schema and sample data
βββ buy-now.js # JavaScript for buy functionality
βββ main.js # Main JavaScript file
βββ styles.css # Main stylesheet
βββ README.md # This file
- Install XAMPP (or any local server with PHP and MySQL)
- Start Apache and MySQL services
- Create Database:
- Open phpMyAdmin (http://localhost/phpmyadmin)
- Import the
database.sqlfile - This will create the
cars24_dbdatabase with all necessary tables
-
Place files in your XAMPP htdocs folder:
C:\xampp\htdocs\Cars24\ -
Configure Database (if needed):
- Edit
config/database.php - Update database credentials if different from default
- Edit
-
Open your browser and go to:
http://localhost/Cars24/ -
For dynamic version (recommended):
http://localhost/Cars24/index.php
id- Primary keyusername- Unique usernameemail- Unique email addresspassword- Hashed passwordfull_name- User's full namephone- Phone numberaddress- User addresscreated_at- Registration timestamp
id- Primary keyname- Car namebrand- Car brandmodel- Car modelyear- Manufacturing yearprice- Car priceimage- Car image pathdescription- Car descriptionfeatures- JSON featuresrating- Average ratingreviews_count- Number of reviewsstatus- Available/Sold/Reserved
id- Primary keyuser_id- Foreign key to userscar_id- Foreign key to carspurchase_date- Purchase timestamptotal_amount- Purchase amountpayment_method- Payment method usedpayment_status- Payment statusdelivery_address- Delivery addressdelivery_date- Preferred delivery datenotes- Additional notes
- Registration: New users create an account
- Login: Users authenticate to access purchase features
- Browse Cars: View cars by brand category
- Select Car: Click "Buy Now" on desired car
- Purchase Form: Fill in delivery and payment details
- Complete Purchase: Car status updates to "sold"
- Username and email uniqueness validation
- Password confirmation
- Form validation and error handling
- Secure password hashing
- Username or email login
- Session management
- Secure authentication
- Automatic redirect after login
- Auto-filled buyer information
- Multiple payment methods
- Delivery address and date selection
- Purchase confirmation
- Database transaction handling
- Dynamic car loading from database
- Brand-based categorization
- Real-time availability status
- Feature display with icons
- Password Hashing: Uses PHP's
password_hash()function - SQL Injection Prevention: Prepared statements
- XSS Prevention: Input sanitization
- Session Management: Secure session handling
- Input Validation: Server-side validation
- Add car data to the
carstable - Include car image in
assets/folder - Update features JSON as needed
- Edit
styles.cssfor visual changes - Update color variables in CSS root
- Extend database schema as needed
- Update PHP files for new functionality
- Modify JavaScript for enhanced interactions
-
Database Connection Error:
- Check if MySQL is running
- Verify database credentials in
config/database.php - Ensure database
cars24_dbexists
-
Page Not Loading:
- Check if Apache is running
- Verify file permissions
- Check for PHP syntax errors
-
Images Not Displaying:
- Ensure
assets/folder contains all images - Check file paths in HTML
- Ensure
-
Purchase Not Working:
- Verify user is logged in
- Check database permissions
- Review PHP error logs
- β Chrome (recommended)
- β Firefox
- β Safari
- β Edge
- Backend: PHP 7.4+
- Database: MySQL 5.7+
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Icons: Remix Icons
- Sliders: Swiper.js
- Animations: ScrollReveal
This project is for educational purposes. Feel free to modify and use as needed.
For issues or questions, please check the troubleshooting section above or review the code comments for guidance.