-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.php
More file actions
41 lines (32 loc) · 942 Bytes
/
Copy pathConnection.php
File metadata and controls
41 lines (32 loc) · 942 Bytes
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
<?php $currentFolder = 'TrackingAdmin';?>
<?php
function getConnection(){
$server = "localhost";
$username = "bammobic";
$password = "abcmtk123";
$database = "bidomanager";
$connection = mysql_connect($server, $username, $password);
if(!$connection){
echo '<p>Có lỗi xảy ra</p>';
exit();
}
if(!mysql_select_db($database)){
echo '<p>Cannot Connect to database</p>';
exit();
}
mysql_query("SET character_set_results=utf8", $connection);
return $connection;
}
?>
<?php
function getUser($username, $password){
$connection = getConnection();
$query = "Select * FROM User Where `username` = $username AND `password` = $password";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if(is_null($row))
return -1;
return $row['Id'];
mysql_close($connection);
}
?>