Here is the updated script.. does the while loop look plausible?
I am trying to make it so that two people cannot register with the same name.
PHP Code:
<?php
require 'config.php';
$result = mysql_query('SELECT * FROM users') or die('Could not gather info: ' . mysql_error());
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$password = sha1($_POST['password']);
$ip = $_SERVER['REMOTE_ADDR'];
$registered = date("F j, Y, g:i a");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
if ($username != $line['username'])
{
$query = 'INSERT INTO users (username, password, registration_date, user_ip) VALUES('.$username.', '.$password.', '.$registered.', '.$ip.')';
$result = mysql_query($query);
}
}
}
else
{
echo 'Die Hacking Attempt!';
}
?>
New problem
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'localhost, root, ' (11004) in C:\Program Files\wamp\www\tyrant\config.php on line 8
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\wamp\www\tyrant\config.php on line 9
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\Program Files\wamp\www\tyrant\config.php on line 9
Could not select database
PHP Code:
<?php
$dbname = 'tyrant';
$dbuser = 'root';
$dbhost = 'localhost';
$dbpass = '';
mysql_connect($dbhost.', '.$dbuser.', '.$dbpass);
mysql_select_db($dbname) or die('Could not select database');
?>
Fixed problem
Bookmarks