0% found this document useful (0 votes)
1 views2 pages

PHP

Uploaded by

nene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

PHP

Uploaded by

nene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php
$servername="localhost";
$username="root";
$password="";

try {
$bdd = new PDO("mysql:host=$servername;dbname=boutique",$username,$password);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
echo $e->getmessage();
}
/////////////////
<?php
include("connexion.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ma Boutique</title>
</head>
<body>
<div id="conteneur">
<h1>BIENVENU DANS MA BOUTIQUE</h1>
<hr>
<ul>

<li><a href="article.php"> CREER UN ARTICLE</li>


<li><a href="liste.php">LISTE DES ARTICLES</li>
</ul>
</div>

</body>
</html>

?>
////////////////////////////////
<?php
require_once("connexion.php");

1
if(isset($_POST['valider'])){

$code =$_POST['code'];
$designation =$_POST['designation'];
$categorie =$_POST['categorie'];
$pu =$_POST['pu'];

$stmt = $bdd->prepare("INSERT INTO articles (code,designation,categorie,pu) VALUES (?,?,?,?) ");


$stmt->execute(array($code,$designation,$categorie,$pu));
}

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Article</title>
</head>
<body>
<h2>ENREGISTREMENT DES ARTICLES</h2>
<form method="POST" action="">
CODE <br>
<input type="text" name="code" placeholder="Entrez le code"><br><br>

DESIGNATION <br>
<input type="text" name="designation" placeholder="Entrez la designation"><br><br>

CATEGORIE <br>
<select name="categorie">
<option value="ordinateur">ORDINATEUR</option>
<option value="imprimante">IMPRIMANTE</option>
</select><br><br>
PU <br>
<input type="text" name="pu"><br><br>
<button name="valider">ENREGISTRER</button>
</form>

</body>
</html>

You might also like