--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/index.php Tue May 19 00:30:06 2009 +0100
@@ -0,0 +1,61 @@
+<?php
+ $conn = mysql_connect('localhost','root','') or die(mysql_error());
+ mysql_select_db('h4c_db');
+
+ // retrieve cookie if it exists
+ if (isset($_COOKIE['h4c_ID']))
+ {
+ $currID = $_COOKIE['h4c_ID'];
+ }
+ else
+ {
+ // SQL queries
+ $result = mysql_query("INSERT INTO users_tbl (user_ID) VALUES ('')");
+ $user_id = mysql_query("SELECT MAX(user_ID) as id FROM users_tbl");
+
+ $expiry = time() + (3600 * 24 * 30 * 12);
+
+ //create cookies
+ while ($db_field2 = mysql_fetch_assoc($user_id)) {
+ setcookie('h4c_ID', $db_field2['id'] , $expiry, '/', '', 0);
+ }
+
+ if (!isset($_COOKIE['h4c_ID']))
+ {
+ $currID = 1;
+ }
+ }
+
+ mysql_close();
+
+ header ('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/details.php');
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>H4C - checking your user status...</title>
+</head>
+
+<body>
+<?php
+ // FOR TEST PURPOSES - CHECK COOKIE VALUES
+ /*
+ print '<p><strong>COOKIES------------------------------------------------------------------------</strong></p>';
+ print 'COOKIE ID = ' . $currID . '<br />';
+ print 'COOKIE Status = ' . $currStatus . '</p>';
+
+ // FOR TEST PURPOSES - READ USERS
+ $result2 = mysql_query('SELECT * FROM users_tbl');
+
+ print '<p><strong>LIST OF USERS -----------------------------------------------------------------</strong></p><p>';
+
+ while ($db_field = mysql_fetch_assoc($result2)) {
+ print 'USERID: ' . $db_field['user_ID'] . ' | EMAIL: ' . $db_field['user_email'] . ' | USERSTATUS: ' . $db_field['user_status'] . '<br />';
+ }
+
+ print '</p>';
+ */
+?>
+</body>
+</html>