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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| <?phprequire_once 'connexion.php';
if(isset($_POST['submit'])){
//On vérifie si la variable existe et sinon elle vaut NULL
$num = isset($_POST['num']) ? $_POST['num'] : NULL;
$client = isset($_POST['client']) ? $_POST['client'] : NULL;
$datefacture = isset($_POST['datefacture']) ? $_POST['datefacture'] : NULL;
$facturede = isset($_POST['facturede']) ? $_POST['facturede'] : NULL;
$conditions = isset($_POST['conditions']) ? $_POST['conditions'] : NULL;
$tva = isset($_POST['tva']) ? $_POST['tva'] : NULL;
$filename = $_FILES['files']['name'];
$chemin= 'upload/'.$filename ;
$chemintemp = $_FILES['files']['tmp_name'] ;
$req1 = $base->prepare('INSERT INTO infosfacture (num, client, datefacture, facturede, conditions, tva, name, image)
VALUES (:num, :client, :datefacture, :facturede, :conditions, :tva, :name, :image)');
$statement = $base->prepare($req1);
$param = array();
$params[':num'] = $_POST['num'];
$params[':client'] = $_POST['client'];
$params[':datefacture'] = $_POST['datefacture'];
$params[':facturede'] = $_POST['facturede'];
$params[':conditions'] = $_POST['conditions'];
$params[':tva'] = $_POST['tva'];
$params[':name'] = $filename;
$params[':image'] = $chemin;
$ext = end((explode(".", $filename)));
// Valid image extension
$valid_ext = array("png","jpeg","jpg");
if(in_array($ext, $valid_ext)){
// Upload file
if(move_uploaded_file($chemintemp,$chemin)){
// Execute query
$statement->execute($params);
}
}
}
// Get extension
$ext = end((explode(".", $filename)));
// Valid image extension
$valid_ext = array("png","jpeg","jpg");
if(in_array($ext, $valid_ext)){
// Upload file
if(move_uploaded_file($_FILES['files']['tmp_name'],'upload/'.$filename)){
// Execute query
$statement->execute(array($filename,'upload/'.$filename));
}
}
}
?> |
Partager