-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_details.php
42 lines (32 loc) · 1.17 KB
/
user_details.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
<?php
// Connection parameters
$host = 'cspp53001.cs.uchicago.edu';
$username = 'meyer7';
$password = '37Mt4bwu11';
$database = $username.'DB';
// Attempting to connect
$dbcon = mysqli_connect($host, $username, $password, $database)
or die('Could not connect: ' . mysqli_connect_error());
//print 'Connected successfully!<br>';
// Selecting a database
// Unnecessary in this case because we have already selected
// the right database with the connect statement.
mysqli_select_db($dbcon, $database)
or die('Could not select database');
//print 'Selected database successfully!<br>';
$user = $_GET["user"];
// Listing tables in your database
$query = "SELECT userID, handle, name, email, accountCreate, lastLogin, accountActive, isOfficial, following, followers FROM users WHERE handle =\"$user\"";
$result = mysqli_query($dbcon, $query)
or die('Describe user failed: ' . mysqli_error());
$json = array();
while ($tuple = mysqli_fetch_row($result)){
//print $tuple;
array_push($json, $tuple);
}
// Free result
mysqli_free_result($result);
// Closing connection
mysqli_close($dbcon);
echo json_encode($json);
?>