-
Notifications
You must be signed in to change notification settings - Fork 0
/
insertClient.php
115 lines (63 loc) · 2.58 KB
/
insertClient.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
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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "../hotel/db/db.php";
date_default_timezone_set('Europe/Rome');
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myhotel";
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn == false){
die("ERROR : could not connect. "
. mysqli_connect_error());
}
if(isset($_REQUEST["user_name"]))
{
$userName = $_REQUEST["user_name"];
$userSurname = $_REQUEST["user_surname"];
$userAddress = $_REQUEST["user_address"];
$userZipcode = $_REQUEST["user_zipcode"];
$userPhone = $_REQUEST["user_phone"];
$sql = "INSERT INTO myhotel.users ( user_name , user_surname , user_address , user_zipcode , user_phone ) VALUES
('$userName' , '$userSurname' , '$userAddress' , '$userZipcode' , '$userPhone' )";
if(mysqli_query($conn, $sql)){
$toReturn =
'<div class=" container mt-3 card text-center" style="width: 18rem;">
<img src="https://cdn.pixabay.com/photo/2016/10/16/21/30/halloween-1746354__340.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Name : '.$userName.'</h5>
<h5 class="card-title">Surname : '.$userSurname.'</h5>
<h5 class="card-title">Address : '.$userAddress.'</h5>
<h5 class="card-title">Zipcode : '.$userZipcode.'</h5>
<h5 class="card-title">Phone number : '.$userPhone.'</h5>
<p class="card-text">User has been stored in Hotel Database successfully</p>';
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
//close connection
mysqli_close($conn);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- bootstrap link -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- bootstrap link -->
<link rel="stylesheet" href="./css/styles.css">
<title>Document</title>
<div class="container">
<?php
echo $toReturn;
?>
</div>
</head>
<body>
</body>
</html>