-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.php
80 lines (53 loc) · 1.8 KB
/
connection.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
<?php
// // $host = "host=localhost";
// // $port = "port=5432";
// // $dbname = "dbname=postgres";
// // $credentials = "user=postgres password=satyam@4545";
// // $connectionString = "$host $port $dbname $credentials";
// // $db = pg_connect($connectionString);
// // if (!$db) {
// // echo "error: unable to open database";
// // } else {
// // echo "opened";
// //
// $serverhost = "localhost:3307";
// $user = "root";
// $password = "";
// $database = "satyam";
// // Create a new MySQLi object and establish a connection
// $connect = new mysqli($serverhost, $user, $password, $database);
// // Check if the connection was successful
// if ($connect->connect_error) {
// die("Connection failed: " . $connect->connect_error);
// }
// // Successful connection
// echo "Database connected successfully.";
// Perform database operations here...
// Close the connection
$serverhost = "localhost:3307";
$user = "root";
$password = "";
$database = "satyam";
// Create a new MySQLi object and establish a connection
$connect = new mysqli($serverhost, $user, $password, $database);
// Check if the connection was successful
if ($connect->connect_errno) {
print( "database connection failed");
exit();
}
// $username=$_POST['username'];
// $password=$_POST['password'];
// $sql="SELECT * FROM logg WHERE username='".$username."'AND password='".$password."'";
// $result=mysqli_query($connect,$sql);
// $count=mysqli_num_rows($result);
// if ($count == 1) {
// echo json_encode(array("response" => "error"));
// } else {
// $insert = "INSERT INTO logg(username, password) VALUES ('".$username."', '".$password."')";
// $query = mysqli_query($connect, $insert);
// if ($query) {
// echo json_encode(array("response" => "success"));
// }
// }
// Successful connection
?>