-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation_ajout.php
39 lines (32 loc) · 1.28 KB
/
validation_ajout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
if(isset($_POST['Ajouter'])){
session_start();
// print_r($_SESSION);
$id=$_SESSION['id'];
$username=$_SESSION['username'];
$target_dir = $username."/images";
$target_file = $target_dir . str_replace(" ","_",basename($_FILES["photo"]["name"]));
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); //maj
if (move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["photo"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
$nproduit=$_POST["nproduit"];
$prix=$_POST["prix"];
$photo= $target_file;
echo $id;
echo $prix;
echo $nproduit;
echo $photo;
$cnx = mysqli_connect("localhost","root","","projetphp") or die ("erreur");
// mysqli_select_db("projetphp") or die ("la bd est introuvbable");
$query="INSERT INTO produit (id,nomproduit,prix,image) VALUES ('$id','$nproduit','$prix','$photo')";
// echo $query;
// $query='INSERT INTO produit (id,nomproduit,prix,image) VALUES ("'.$id.'","'.$nproduit.'","'.$prix.'","'.$photo.'")';
mysqli_query($cnx,$query) or die ('erreur :' .mysql_error());
echo "OK!";
header("Location:store.php");
}
?>