1 <?php |
1 <?php |
2 $conn = mysql_connect('localhost','root','') or die(mysql_error()); |
2 $conn = mysql_connect('localhost','www-data','www-data') or die(mysql_error()); |
3 mysql_select_db('h4c_db'); |
3 mysql_select_db('members'); |
4 |
4 |
5 // retrieve cookie if it exists |
5 // retrieve cookie if it exists |
6 if (isset($_COOKIE['h4c_ID'])) |
6 if (isset($_COOKIE['n4c_ID'])) |
7 { |
7 { |
8 $currID = $_COOKIE['h4c_ID']; |
8 $currID = $_COOKIE['n4c_ID']; |
9 } |
9 } |
10 else |
10 else |
11 { |
11 { |
12 // SQL queries |
12 // SQL queries |
13 $result = mysql_query("INSERT INTO users_tbl (user_ID) VALUES ('')"); |
13 $result = mysql_query("INSERT INTO creds (uid) VALUES ('')"); |
14 $user_id = mysql_query("SELECT MAX(user_ID) as id FROM users_tbl"); |
14 $user_id = mysql_query("SELECT MAX(uid) as id FROM creds"); |
15 |
15 |
16 $expiry = time() + (3600 * 24 * 30 * 12); |
16 $expiry = time() + (3600 * 24 * 30 * 12); |
17 |
17 |
18 //create cookies |
18 //create cookies |
19 while ($db_field2 = mysql_fetch_assoc($user_id)) { |
19 while ($db_field2 = mysql_fetch_assoc($user_id)) { |
20 setcookie('h4c_ID', $db_field2['id'] , $expiry, '/', '', 0); |
20 setcookie('n4c_ID', $db_field2['id'] , $expiry, '/', '', 0); |
21 } |
21 } |
22 |
22 |
23 if (!isset($_COOKIE['h4c_ID'])) |
23 if (!isset($_COOKIE['n4c_ID'])) |
24 { |
24 { |
25 $currID = 1; |
25 $currID = 1; |
26 } |
26 } |
27 } |
27 } |
28 |
28 |
32 ?> |
32 ?> |
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
34 <html xmlns="http://www.w3.org/1999/xhtml"> |
34 <html xmlns="http://www.w3.org/1999/xhtml"> |
35 <head> |
35 <head> |
36 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
36 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
37 <title>H4C - checking your user status...</title> |
37 <title>N4C - checking your user status...</title> |
38 </head> |
38 </head> |
39 |
39 |
40 <body> |
40 <body> |
41 <?php |
41 <?php |
42 // FOR TEST PURPOSES - CHECK COOKIE VALUES |
42 // FOR TEST PURPOSES - CHECK COOKIE VALUES |
44 print '<p><strong>COOKIES------------------------------------------------------------------------</strong></p>'; |
44 print '<p><strong>COOKIES------------------------------------------------------------------------</strong></p>'; |
45 print 'COOKIE ID = ' . $currID . '<br />'; |
45 print 'COOKIE ID = ' . $currID . '<br />'; |
46 print 'COOKIE Status = ' . $currStatus . '</p>'; |
46 print 'COOKIE Status = ' . $currStatus . '</p>'; |
47 |
47 |
48 // FOR TEST PURPOSES - READ USERS |
48 // FOR TEST PURPOSES - READ USERS |
49 $result2 = mysql_query('SELECT * FROM users_tbl'); |
49 $result2 = mysql_query('SELECT * FROM creds'); |
50 |
50 |
51 print '<p><strong>LIST OF USERS -----------------------------------------------------------------</strong></p><p>'; |
51 print '<p><strong>LIST OF USERS -----------------------------------------------------------------</strong></p><p>'; |
52 |
52 |
53 while ($db_field = mysql_fetch_assoc($result2)) { |
53 while ($db_field = mysql_fetch_assoc($result2)) { |
54 print 'USERID: ' . $db_field['user_ID'] . ' | EMAIL: ' . $db_field['user_email'] . ' | USERSTATUS: ' . $db_field['user_status'] . '<br />'; |
54 print 'USERID: ' . $db_field['uid'] . ' | EMAIL: ' . $db_field['user_email'] . ' | USERSTATUS: ' . $db_field['user_status'] . '<br />'; |
55 } |
55 } |
56 |
56 |
57 print '</p>'; |
57 print '</p>'; |
58 */ |
58 */ |
59 ?> |
59 ?> |