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
|
<?php
session_start();
// On inclus les fichiers necessaires
// sécurisation à l'affichage
$hsc = function($p) { return htmlspecialchars($p, ENT_QUOTES); };
if(!isset($_SESSION['pseudo']))
{
header("Location: index.php");
}
$enr = mysql_query('SELECT * FROM utilisateur WHERE id_utilisateur = "'.$_SESSION["id"].'"');
$row = mysql_fetch_assoc($enr);
$level = $row["User_Rang"];
if($level != 1)
{
header("Location: index.php");
}
?>
<?php
if(isset($_POST['send']))
{
if(!empty($_POST["ttr_title"]) AND !empty($_POST['ttr_content']) AND !empty($_POST["ttr_desc"]) AND !empty($_POST["ttr_temps"]))
{
// Création des variables aux noms abrégés
$id_user = mysql_real_escape_string($_SESSION['id']);
$datetime = date('Y-m-d H:i:s');
$title = mysql_real_escape_string($_POST["ttr_title"]);
$desc = mysql_real_escape_string($_POST["ttr_desc"]);
$content = mysql_real_escape_string($_POST["ttr_content"]);
$temps = mysql_real_escape_string($_POST["ttr_temps"]);
$prix = mysql_real_escape_string($_POST["ttr_prix"]);
$type = mysql_real_escape_string($_POST["ttr_type"]);
$img_vignette = mysql_real_escape_string($_POST["image_vignette"]);
$img_normale = mysql_real_escape_string($_POST["image_normale"]);
$img_popup = mysql_real_escape_string($_POST["image_popup"]);
$lgc_id = mysql_real_escape_string($_POST["lgc_id"]);
$table = "tutoriel";
$enr=mysql_query("INSERT INTO $table(ttr_id, ttr_title, ttr_content, ttr_desc, ttr_prix, ttr_date, ttr_temps, ttr_type ) VALUES('','$title', '$content', '$desc', '$prix','$datetime', '$temps', '$type') ") or die ("Erreur requette ".mysql_error());
$insertion_image=mysql_query(" INSERT INTO image (id_image, image_vignette, image_normale, image_popup) VALUES ('','".$_POST["image_vignette"]."','".$_POST["image_normale"]."','".$_POST["image_popup"]."')");
$update = mysql_query("UPDATE tutoriel SET logiciel_id = '.$lgc_id' ");
$resultat = "<div class='err'>Tutoriel ajouté !<br><b style='color:green;'>Le tuto est ajouté en BDD.</b></div>";
header ("Refresh: 1;URL=add-tutos.php");
mysql_close();
}
else
{
$resultat = "<div class='err'>Erreur !<b>Attention, tous les champs ne sont pas remplis.</b></div>";
}
echo $resultat;
}
?> |