-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraitementAjouterSujet.php
More file actions
49 lines (42 loc) · 1.92 KB
/
traitementAjouterSujet.php
File metadata and controls
49 lines (42 loc) · 1.92 KB
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
<?php
session_start();
include('BDD.php');
$erreurCommentaire = 'NULL';
$erreurTitre = 'NULL';
//on recupère les variables
$i = 0; //variable qui compte le nombre d'erreur
$date_creation = date("Y-m-d H:i:s");
$commentaire = ($_POST['commentaire']);
$nom = ($_POST['titre']);
$idSouscategorie = $_POST['idSouscategorie'];
$idPseudo = $_SESSION['ID'];
//vérification du titre du sujet et du commentaire
if (strlen($nom) < 3) {
echo'erreurTitre="votre titre est trop court"';
$i++;
}
else if (strlen($_POST['commentaire']) < 4 && strlen($_POST['commentaire']) > 300) {
echo'$erreurCommentaire="votre commentaire est soit trop long, soit trop court"';
$i++;
}
else if ($i == 0 AND $_SESSION['SWITCH']== "organisateur") {
$req = $bdd->query('INSERT INTO topicforum (nom,commentaire,date_creation,id_organisateur,id_participant,id_souscategorie)
VALUES ("'.$nom.'","'.$commentaire.'","'.$date_creation.'","'.$idPseudo.'",0,"'.$idSouscategorie.'")');
echo "votre commentaire a bien été pris en compte";
}
else if ($i==0 AND $_SESSION['SWITCH']== "participant") {
$req= $bdd->query('INSERT INTO topicforum (nom,commentaire,date_creation,id_organisateur,id_participant,id_souscategorie)
VALUES ("'.$nom.'","'.$commentaire.'","'.$date_creation.'",0,"'.$idPseudo.'","'.$idSouscategorie.'")');
echo "votre commentaire a bien été pris en compte";
}
?>
<?php
$req=$bdd->query('SELECT souscategorieforum.nom FROM topicforum,souscategorieforum WHERE souscategorieforum.ID=topicforum.id_sousCategorie
AND topicforum.id_sousCategorie='.$idSouscategorie);
while($donnees=$req->fetch()) {
$nomCat=$donnees['nom'];
}
$req-> CloseCursor();
header('Location:'.$nomCat.'.php');
exit();
?>