<html>
<head>
<style>
body {font-family: "Lato", sans-serif;}
/* Style the tab */
div.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
fieldset{
padding-left: 10px;
margin-left: 360px;
margin-right: 380px;
}
/* Style the buttons inside the tab */
div.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of buttons on hover */
div.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
div.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
-webkit-animation: fadeEffect 1s;
animation: fadeEffect 1s;
}
/* Fade in tabs */
@-webkit-keyframes fadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes fadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
</style>
</head>
<body>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'tab1')">
Déposez votre annonce</button>
<button class="tablinks" onclick="openCity(event, 'tab2')">
Annonces en ligne</button>
</div>
<div id="tab1" class="tabcontent">
<fieldset>
<form method="post" action="form.php" enctype='multipart/form-data'>
<input type="radio" name="type" value="Particulier">Particulier
<input type="radio" name="type" value="Professionnel">Professionnel
<br><br>
<label>Nom:</label>
<input type="text" name="name">
<br><br>
<label>Email:</label>
<input type="email" name="email">
<br><br>
<label>Téléphone:</label>
<input type="text" name="tel" required>
<br><br>
<label>Ville:</label>
<select name="ville">
<option value="blank">« Sélectionnez ville »</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct Ville from villes";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<br><br>
<label>Catégorie:</label>
<select name="categ">
<option value="blank"> « Type de voiture » </option>
<option value="occasion">Voitures occasion</option>
<option value="neuf">Voitures neuves</option>
</select>
<br><br>
<label>Sous-catégorie:</label>
<select name="marque">
<option value="blank"> -- Marque --
</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct carbrand from car";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<br><br>
<select name="year">
<option value="blank"> -- Année -- </option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct year from years";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<select name="km">
<option value="blank"> -- Kilométrage --
</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct km from kms";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<br> <br>
<select name="caros">
<option value="blank"> -- Carosserie --
</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct caro from carosserie";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
</select>
<select name="color">
<option value="blank"> -- Couleur --
</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct color from colors";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<br><br>
<select name="carburant">
<option value="blank"> -- Carburant --
</option>
<option value="diesel">Diesel</option>
<option value="electrique">Electrique</option>
<option value="essence">Essence</option>
<option value="gpl">GPL</option>
<option value="hybrid">Hybrid</option>
</select>
<select name="trans">
<option value="blank">-- Transmission --</option>
<option value="auto">Automatique</option>
<option value="manuel">Manuel</option>
<option value="man">Manuel 6</option>
</select>
<br><br>
<select name="cylindre">
<option value="blank">-- Cylindrée du moteur --</option>
<option value="1.4">1.4</option>
<option value="1.5">1.5</option>
<option value="1.6">1.6</option>
<option value="2.0">2.0</option>
<option value="2.2">2.2</option>
<option value="2.5">2.5</option>
</select>
<select name="puissance">
<option value="blank">-- Puissance Fiscale --</option>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
$sl= "SELECT distinct puiss from pusissance";
$std=$conn->query($sl);
$res=$std->fetchAll(PDO::FETCH_COLUMN,0);
for($i=0;$i<count($res);$i++){
echo " <option value=".$res[$i].">".$res[$i]."</option>";
} ?>
</select>
<br><br>
<select name="douane">
<option value="blank">--Etat douanier --</option>
<option value="local">Achetée localement</option>
<option value="etranger">Achetée à l'étranger</option>
</select>
<br><br>
<label>Description de l'annonce:</label>
<textarea id="texte" name="desc" cols="70" rows="8"></textarea>
<br><br>
<label>Prix:</label>
<input type="text" name="prix">DH
<br><br>
<label>Photos:</label>
<input name="photo" type="file" id="uploaded_file">
<br><br>
<input type="submit" name="continue" value="Continue">
</fieldset>
</form>
</div>
<div id="tab2" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>
<script>
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active","");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
</body>
</html>
<?php
$conn=new PDO('mysql:host=localhost;dbname=cars','root','');
if ( isset($_POST['name']) && isset($_POST['email']) &&
isset($_POST['type']) && isset($_POST['tel']) && isset($_POST['ville'])
&& isset($_POST['categ']) && isset($_POST['marque']) &&
isset($_POST['year']) && isset($_POST['km']) && isset($_POST['caros'])
&& isset($_POST['color']) && isset($_POST['carburant'])&&
isset($_POST['trans']) && isset($_POST['cylindre']) &&
isset($_POST['puissance']) && isset($_POST['douane']) &&
isset($_POST['desc']) && isset($_POST['prix'])&& isset($_POST['photo'])
&& isset($_POST['continue'])){
$sql= "INSERT INTO owner VALUES(
'".($_POST['type'])."',
'".$_POST['name']."',
'".$_POST['email']."',
'".$_POST['tel']."',
'".$_POST['ville']."',
'".$_POST['categ']."',
'".$_POST['marque']."',
'".$_POST['year']."',
'".$_POST['km']."',
'".$_POST['caros']."',
'".$_POST['color']."',
'".$_POST['carburant']."',
'".$_POST['trans']."',
'".$_POST['cylindre']."',
'".$_POST['puissance']."',
'".$_POST['douane']."',
'".$_POST['desc']."',
'".$_POST['prix']."',
'".$_POST['photo']."',')";
$res=$conn->query($sql);
}
?>
i have been trying to insert these informations in my database but nothing gets inserted please help (btw i'm still a beginner) im trying to insert the information that the user will fill in the form in my database, when i click on submit the page is blank but when i check my database my informations aren't added