-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
126 lines (94 loc) · 2.36 KB
/
index.php
File metadata and controls
126 lines (94 loc) · 2.36 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
session_start();
//echo 'salut';
$toto_a_la_plage = 'Salut les potes';
//echo $toto_a_la_plage;
$chiffre= 3;
$boolean = true;
$array= ['test', 1, true];
/*Pour afficher le contenu d'un tableau */
echo "<pre>";
var_dump($array);
echo "</pre>";
echo "<pre>";
print_r($array);
echo "</pre>";
$multi_dimensional_array = [
'toto' => 'Salut les gars',
'tata' => 34,
'titi' => false,
'tonton' => function($papa = 'de taré') {
if (is_string($papa)){
$content = 'je suis une fonction ' . $papa . " mais pas trop ...";
}else{
$content = 'Tu t\'es raté mon copain, car "$papa" est de type <b>' . gettype($papa) . '</b>';
}
return $content;
},
'tutu' => [
'bof' => 'Je sais plus quoi mettre ...',
'bif' => 45
]
];
echo "<pre>";
var_dump($multi_dimensional_array);
echo "</pre>";
?>
<br>
<hr>
<br>
<?php
echo $array[0];
echo "<pre>";
echo $multi_dimensional_array['toto'];
echo "</pre>";
echo "<pre>";
echo $multi_dimensional_array['tutu']['bof'];
echo "</pre>";
echo "<pre>";
echo $multi_dimensional_array['tonton']();
echo "</pre>";
echo "<pre>";
echo $multi_dimensional_array['tonton']('de foufou');
echo "</pre>";
echo "<pre>";
echo $multi_dimensional_array['tonton'](24);
echo "</pre>";
?>
<br>
<hr>
<br>
<?php
echo "<pre>";
echo var_dump($_GET); //Super globaale
echo "</pre>";
?>
<?php
if (isset($_POST['logout'])) { // On vérifie si on s'est déconnecté
session_destroy();
header('Location: index.php');
}
?>
<?php
if (!isset($_SESSION['firstname']) && isset($_POST['firstname']) && !empty($_POST['firstname'])){ // On vérifie si on est connecté
$_SESSION['firstname'] = $_POST['firstname'];
}
?>
<?php
if (!isset($_SESSION['firstname']) || isset($_POST['logout'])) {
// Si $_SESSION['firstname'] n'existe pas ou que l'on s'est déconnecté alors
?>
<form method="post">
<label>Mon Prénom:</label>
<input type="text" name="firstname">
<label>Mon MDP:</label>
<input type="password" name="password">
<button type="submit">Valider</button>
</form>
<?php }else{ //SINON ?>
<p>Salut <b><?= $_SESSION['firstname'] ?></b></p>
<form method="post">
<input type="hidden" name="logout" value="bisou">
<button type="submit">Déconnexion</button>
</form>
<?php } ?>