Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases

Form not submitted into database.

Hello can anybody check any mistakes in my coding? i tried to create a submission form, everything looks fine, no error message, but when i fill all details any try to submit it, it redirect to same page without appearing any successful message, and the data do not insert into phpmyadmin database. here's my coding

<?php session_start(); if ($_SESSION['login_user'] == "") header("Location:logout.php"); include('database.php'); ?> <!-- Iridium by TEMPLATED templated.co @templatedco Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) --> <html> <head> <title>Booking</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <link href='http://fonts.googleapis.com/css?family=Arimo:400,700' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed|Open+Sans+Condensed:300' rel='stylesheet' type='text/css'> <!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]--> <script src="http://ajax.googleapis.com/…/li…/jquery/1.11.0/jquery.min.js"></script> <script src="js/skel.min.js"></script> <script src="js/skel-panels.min.js"></script> <script src="js/init.js"></script> <noscript> <link rel="stylesheet" href="css/skel-noscript.css" /> <link rel="stylesheet" href="css/admin_style.css" /> <link rel="stylesheet" href="css/style-desktop.css" /> </noscript> <!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]--> <!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]--> </head> <body> <!-- Header --> <div id="header"> <div class="container"> <!-- Logo --> <div id="logo"> <h1>R & G</h1> <span>Click & Drive</span> </div> <!-- Nav --> <nav id="nav"> <ul> <li><a href="homepage_admin.php">Homepage</a></li> <li class="active"><a href="addcar_admin.php">Add Car</a></li> <li><a href="changepassword_admin.php">Change Password</a></li> <li><a href="addadmin_admin.php">Add Admin</a></li> <li><a href="checkbooking_admin.php">Check Booking</a></li> <li><a href="logout.php">Log Out</a></li> </ul> </nav> </div> </div> <!-- Main --> <div id="main"> <div class="container"> <link rel="stylesheet" href="css/admin_style.css" /> <div class="row"> </div> <!-- Content --> <!--<div id="content" class="11u skel-cell-important">--> <section> <script src="js/scriptimage.js"></script> <link rel="stylesheet" href="css/style_admin.css" /> </section> <!--<a href="#" class="image full"><img src="images/pic07.jpg" alt="" /></a>--> <div style="text-align:center;"> <form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> <label class="labelwarning"> Make sure the car is a cheap car.</label> </br></br> <label>Car Name</label> </br> <input type="text" name="car_name" required> </br> <label>Car Color</label> </br> <input type="text" name="car_color" required> </br> </br> <label>Transmission Type</label> </br> <select name="car_transmission" required> <option value="">Select Transmission</option> <option value="M">Manual</option> <option value="A">Auto</option> </select> </br> </br> <div id="image_preview"><img id="previewing" src="images/noimage.png" /></div> <div id="selectImage"> <label>Select Your Image</label><br/> <input type="file" name="fileToUpload" id="file" required /> </div> <div id="message"></div> </br> <label>NO Plate</label> </br> <input type="text" class=text2 name="car_plate" required> </br> <label>Price per Day</label> </br> <input type="text" class=text2 name="car_price" required> </br> </br> </br> <input type="submit" name="submit" value="Submit"> </div> </div> </div> </div> </div> <!-- Footer --> <div id="featured"> <div class="container"> <div class="row"> <h2>Our Company Details</h2> <p>Rent and Go Rental is one of the class's best-known car rental brands. Design owned by a person who created this template, which operates and licenses the brand throughout the Internet. Rent and Go Rental was founded in 2016 as a car rental company for the "budget and melayu minded" renter. So everyone can drive like Malay.</p> <!-- <p><a href="#" class="button">More Details</a></p>--> </div> </div> </div> </div> <?php if(isset($_POST['submit'])){ $carname_temp = $_POST['car_name']; $carcolor_temp = $_POST['car_color']; $cartranmission_temp = $_POST['car_transmission']; $carplate_temp = $_POST['car_plate']; $carprice_temp = $_POST['car_price']; $query = mysql_query("INSERT INTO Car_Type(CarName,PricePerHour) VALUES ('$carname_temp', $carprice_temp)"); if($query){ $query2 = mysql_query("INSERT INTO Car_Info(PlateNo,Transmission_Type,Colour,Check_Availability,CarTypeID) SELECT '$carplate_temp','$cartranmission_temp', '$carcolor_temp', 'Y', CarTypeID FROM Car_Type WHERE CarName = '$carname_temp'"); if($query2){ ?> <script> alert("New car added"); </script> <?php } } $query3 = mysql_query("SELECT * FROM Car_Type ORDER BY CarTypeID DESC LIMIT 1"); $row4 = @mysql_fetch_array($query3); $fileName = $_FILES['fileToUpload']['name']; $tmpName = $_FILES['fileToUpload']['tmp_name']; $filesize = $_FILES['fileToUpload']['size']; $filetype = $_FILES['fileToUpload']['type']; //remove space if file name $fileName=str_replace (' ', '',$fileName); $newfilename = $row4['CarTypeID'].'.jpg'; //file upload coding here move_uploaded_file($_FILES['fileToUpload']['tmp_name'], "images/$newfilename"); } ?> <!-- Copyright --> <div id="copyright"> <div class="container"> Design: © Copyright 2016 R&G Car Enterprise. All Rights Reserved. </div> </div> </body> </html> If u guys need full system including the database.sql file, let me know i'll give it to you thorugh your email. Thank you in advance for helping me