Hi im trying to get the if statment to work with checkhing for a user if he exist..
if not it shoulde print Ooops! - The nickname you chose don't exists! what have i misst!
<?php
$username = $_POST["username"];
$set = $_POST["set"];
function emailsyntax_is_valid($email) {
$to_work_out = explode("@", $email);
if (!isset($to_work_out[0])) return FALSE;
if (!isset($to_work_out[1])) return FALSE;
$pattern_local = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$';
$pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$';
$match_local = eregi($pattern_local, $to_work_out[0]);
$match_domain = eregi($pattern_domain, $to_work_out[1]);
if ($match_local && $match_domain) {
return TRUE;
}
return FALSE;
}
if ($set=="set") {
$username_control = 1;
$username2_control = 1;
$username3_control = 1;
$main_control = 1;
if($username == ""){
$empty_username = "Ooops! - You forgot to enter your username.";
$username_control = 0;
$main_control = 0;
}
elseif(strlen($username) < 4){
$empty_username = "Ooops! - Your username should be at least 4 letters long.";
$username2_control = 0;
$main_control = 0;
}
elseif(strlen($username) > 20){
$empty_username = "Ooops! - Your username can't be larger than 20 letters.";
$username3_control = 0;
$main_control = 0;
}
elseif($main_control = 1){
$str = $username;
$str = strtolower($str);
require ('mysqlcondbrr.php');
$result = mysql_query("SELECT username FROM reg_info where username=$str", $starta);
while ($array = mysql_fetch_array($result)) {
if($str == $array["username"]) {
$empty_username = "Ooops! - The nickname you chose don't exists!";
$main_control2 = 1;
break;
mysql_close($starta);
}
}
}
}
if($main_control2 != 1 && $main_control == 1) {
}
?>
<?PHP
function info() {
}
print "Please enter your usernamen in the blank field <br>
below then after press get password button to <br>
get your password.<br>";
function validuser()
{
print "Welcome $_POST[username].in some seconds you <br>
will recive a email with your password in it.<br>";
function invaliduser() {
}
print "Sorry, incorrect username ( $_POST[username] ).<br>
if not a member <a href=\"register.php\">click here to register.</a>";
}
?>
<br>
<form action="<?=$PHP_SELF?>" method="post" name="hej">
<b>Your Username Here:</b><br><br>
<input type="text" name="username" size="15" class="inputSidebar" value="<?php
if($username_control != 0){ echo $_POST['username'];}
elseif(username2_control !=0){ echo $_POST['username'];}
elseif(username3_control !=0){ echo $_POST['username'];}
else{ echo ''; } ?>">
<?php echo $empty_username; ?>    
<input class="button" type="submit" name="submit" value="Get password">
<?php echo $_POST['username']; ?>
<input type="hidden" name="set" value="set">
</form>