Maybe you get the error, because you're allways updating the database.
This is your script structure:
<?php
if($Username == '')
{
}
elseif ($Password == '')
{
}
else
{
if($username_check > 0)
{
}
}
?>
'
After you've checked if the username is still available, you close the 'else' and updat the database.
I think it has to be something like this:
<?php
include("settings.inc");
if($Username == '')
{
print("Please enter a username");
}
elseif ($Password == '')
{
print("Please enter a password");
}
else
{
$Username = $_POST['Username'];
mysql_select_db("Secure", $connection);
$query1 = "SELECT Username FROM Usersettings WHERE Username='$Username'";
$result1 = mysql_query($query1) or die("ERROR");
$username_check = mysql_num_rows($result1);
if($username_check > 0)
{
echo "We apologize, but the username you have selected has already been used by another member in our database. Please choose a different Username.<br><br>";
unset($username);
}
mysql_select_db("Secure", $connection);
$query2 = "INSERT INTO Usersettings (Username, Password) VALUES ('$Username', '$Password')";
$result = mysql_query($query2) or die("ERROR");
print("<script> location.href='index.php?Msg=User succesfully added' </script>"};
}
?>