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
| <?php
if(isset($_POST['infos'])) $infos=$_POST['infos'];
else $infos="";
if(isset($_POST['infosfr'])) $infosfr=$_POST['infosfr'];
else $infosfr="";
if(isset($_POST['title'])) $title=$_POST['title'];
else $title="";
if(isset($_POST['immat'])) $immat=$_POST['immat'];
else $immat="";
if(isset($_FILES['image']))
{
$dossier = 'photos/';
$fichier = $immat.'.jpg';
if(move_uploaded_file($_FILES['image']['tmp_name'], $dossier . $fichier))
{
fctredimimage(650,0,'photos/',$fichier,'photos/650px/',$fichier);
fctredimimage(75,0,'photos/',$fichier,'photos/thumbs/',$fichier);
if(empty($immat) OR empty($infos) OR empty($infosfr) OR empty($title))
{
echo "";
}
//Aucun champ n'est vide, on peut enregistrer dans la table
else
{
$jpg= $immat .'.jpg';
$db = mysqli_connect($localhost,$login,$pwd,$dbName) or die('Erreur de connexion '.mysql_error());
$sql = "INSERT INTO images(title, immat, jpg, infos, infosfr) VALUES('$title', upper('$immat'), '$jpg', '$infos', '$infosfr')";
$res= $db -> query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
mysqli_close($db);
?> |
Partager