La BDD est deja creer.
Voici quelque extrait de mon code
Merci d'avance ^^
<?php
///
//print_r($_SESSION);
if ($_POST) {
$tmp = array();
$tmp["nom"] = $_POST["nom"];
$tmp["disquedur"] = $_POST["disquedur"];
$tmp["commentaire"] = $_POST["commentaire"];
$tmp["date"] = date("d-m-Y H:i:s");
//print_r($tmp);
//$_SESSION['tab'][] = $tmp;
try {
$sqli = new mysqli("localhost", "rootpma", "9fz3Cn4KAC", "TestStock");
$sqli->query("insert into gestion (nom) values ('','$nom')");
$sqli = $tmp;
} catch (mysqli_sql_exception $e) {
echo "MySQLi Error Code: " . $e->getCode() . "<br />";
echo "Exception Msg: " . $e->getMessage();
exit; // exit and close connection.
}
}
?>
<h2>Formulaire</h2>
<form method="post" action="">
nom :
<input type="text" name="nom" value="<?php echo $nom; ?>"/>
<br><br>
disque dur:
<select name="disquedur" size="1">
<optgroup label="Kingston"></optgroup>
<option>Kingston UV400:<br>
50026B777C01C578:<br>
120go
<optgroup label="Samsung"></optgroup>
<option>Samsung 860EVO:<br>
8806088936017:<br>
500go
<optgroup label="Western Digital"></optgroup>
<option>Western Digital WD500LPCX:<br><br>
WX71AA73VDVKM:<br>
500go
<option>Western Digital WD10EUCX:<br>
WCC0S0968794T:<br>
1000go
<option>Western Digital WD20EZRX:<br>
WCC300975857T:<br>
2000go
<optgroup label="Crucial"></optgroup>
<option>Crucial BX500:<br>
1919E181CF6B:<br>
240go
<option>Crucial MX500:<br>
1918E1FF9936:<br>
500go
</select>
<br><br>
Commentaire:<br>
<textarea name="commentaire" rows="5" cols="40"><?php echo $commentaire; ?></textarea>
<br><br>
<input type="submit" value="Submit">
</form>
<h2>Recapitulatif:</h2>
<table>
<thead>
<tr>
<td>Nom</td>
<td>Date</td>
<td>disque dur</td>
<td>Commentaire</td>
</tr>
</thead>
<tbody>
<?php foreach ($tmp['sqli'] as $element): ?>
<tr>
<td><?php echo $element['nom']; ?></td>
<td><?php echo $element['date']; ?></td>
<td><?php echo $element['disquedur']; ?></td>
<td><?php echo $element['commentaire']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>