-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajout.php
More file actions
50 lines (44 loc) · 1.57 KB
/
ajout.php
File metadata and controls
50 lines (44 loc) · 1.57 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
50
<?php
session_start();
$continue;
/*if($_SESSION['logged'] == false){
header('Refresh: 3; url=connect.php');
echo "Non connecté.<br>Vous allez être redirigé vers la page de connexion dans 3 secondes.";
}else{*/
// recuparation des identifiants grace au form
if (isset ($_POST['valider'])){
var_dump($_POST);
if ($_POST['titre'] == ""){
$continue = false;
}elseif($_POST['texte'] == ""){
$continue = false;
}elseif($_POST['tags'] == ""){
$continue = false;
}else{
$continue = true;
}
if ($continue == true){
$titre=addslashes($_POST['titre']);
$contenu=addslashes($_POST['texte']);
$categorie=$_POST['categorie'];
$tags=addslashes($_POST['tags']);
$auteur=$_SESSION['username'];
$link = mysqli_connect("localhost", "root", "", "projetphp") or die("no CNX");
mysqli_query($link, "INSERT INTO projet(titre, contenu, categorie, tag, auteur) VALUES('$titre', '$contenu', '$categorie', '$tags', '$auteur')");
$login = mysqli_query($link, "SELECT * FROM projet");
while ($res1 = mysqli_fetch_array($login)){
echo $res1["titre"]." - ".$res1["contenu"]." - ".$res1["categorie"]." - ".$res1["tag"]."<br/>";
}
// var_dump($link);
// var_dump("INSERT INTO projet(titre, contenu, categorie, tag, auteur) VALUES('$titre','$contenu','$categorie','$tags','$auteur')");
mysqli_close($link);
echo "job done";
echo "<a href=\"admin.php\">
<button type=\"button\" value=\"return\">Retour</button>
</a>";
}else{
header('Refresh: 3; url=admin.php');
echo "Formulaire incomplet.<br>Redirection dans 3 secondes.";
}
}
?>