Ok, here is my script. First it checks to see if the username is already taken. If that happens it says USername taken etc.
ELSE it redirects to another webpage (i plan to amke this the code where it INSERTS INTO the databse the typed fields.)
But it doesnt. If i type a username which is already taken it tells em so. But if i type a new one it just stays blank!!!
code:
________________________--
<?php
$database = "auth";
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
//QUERIES
$query_checkifexist = "SELECT * FROM authentication WHERE username = '$username'";
$query_final = "INSERT INTO authentication (username, password, realname, age) VALUES ('$username', '$password', '$realname',
'$age')";
//
mysql_connect($dbhost, $dbuser, $dbpass);
$db = mysql_select_db($database);
if (!$db)
die("Failed to open database");
$checkifexist = mysql_query($query_checkifexist);
if ($row = mysql_fetch_array($checkifexist)) {
do {
if ($username === $row[username]){
echo ("Username taken! Please choose another.");
} else {
$final = mysql_query($query_final);
header ("location: [url]http://www.mountaincanon.com[/url]");
}
} while($row = mysql_fetch_array($checkifexist));
}
?>
_________________________________--
Im quite confused as to what is going wrong! I kow it is probably something really simple, but id be grateful for any advice!!
Pablo de la Pena