// in xArray[][] if ($countRow == $m) { $countRow = 0; } $result [$i] = $holder; } // end for return new Matrix ( $result ); } $X = array ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); $nRow = 3; $nCol = 3; $tiled_matrix = tile ( new Matrix ( $X ), $nRow, $nCol ); echo "<pre>"; print_r ( $tiled_matrix ); echo "</pre>"; ?>
<?php $connection = mysql_connect("localhost", "root", "") or die("Could not connect to the database"); mysql_select_db("bean_db", $connection) or die("Could not connect to the database"); error_reporting(0); if ($_POST['login']) { if ($_POST['username'] && $_POST['password']) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(hash("sha512", $_POST['password'])); $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Username`='{$username}'")); if ($user == '0') { die("That username doesn't exist! Try making <i>{$username}</i> today! <a href='index.php'> ← Back</a>"); } if ($user['Password'] == $password) { die("Incorrect password! <a href='index.php'>← Back</a>"); } $salt = hash("sha512", rand() . rand() . rand()); setcookie("c_user", hash("sha512", $username), time() + 24 * 60 * 60, "/"); setcookie("c_salt", $salt, tile() + 24 * 60 * 60, "/"); $userID = $user['ID']; mysql_query("UPDATE `users` SET `Salt`='{$salt}' WHERE `ID`='{$userID}'"); die("You are now logged in as {$username}!"); } } echo "\n\n\t<body style='font-family:verdana, sans-serif;'>\n\t<div style='width: 80%; padding: 5px 15px 5px; border: 1px solid #e3e3e3; background-color: #fff; color: #000;'>\n\t<h1>Login</h1>\n\t<br />\n\t<form action='' method='post'>\n\t<table>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<b>Username:</b>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='username' style='padding:4px;'\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<b>Password:</b>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type='password' name='password' style='padding:4px;'/>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<input type='submit' value='Login' name='login'/>\n\t\t\t</td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<br />\n\t<h6>\n\tNo account? <a href='register.php'>Register!</a>\n\t</h6>\n\t</div>\n\t";