-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveRegion.php
42 lines (28 loc) · 916 Bytes
/
saveRegion.php
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
<?php
session_start();
require_once("query.php");
if ($_POST['action'] == 'save') {
$regionName = trim(str_replace("'", "\\'", $_POST["regionName"]), " \t\n");
if(empty($regionName) || !isset($regionName)){
echo "<script>
alert('Tous les champs doivent être remplis. Ressayez, svp!');
window.location.href='insertRegion.php';
</script>";
}else{
// Préparation de la requête
$sql= "INSERT INTO `region` (`regionName`) VALUES ('".$regionName."')";
if ($conn->query($sql) === TRUE) {
$_SESSION['selectRegion'] = $conn->insert_id;
$conn->close();
// retourne `a page qui a appelle la fonction
include $_SESSION['previousPage'];
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
$conn->close();
}
}
} else{
// retourne `a page qui a appelle la fonction
include $_SESSION['previousPage'];
}
?>