Please help me to figure out what is the problem with this code.I ve tried register and successful.I received the confirmation email (username & password) and i can successfully sign in to the website. But, when i tried with other mail account, i received the confirmation email but i can't sign in to the website. When i checked the database, the registration info was not insert into the database. So, i am really confused why the codes works properly only for the certain mail address and not for all mail address.

Successfully insert to the database (eg:yahoo,gmail)
Didn't save / insert to the database (eg:marin-dbase.com)(my other account for other domains)

Here is the code
PHP Code:
<? include("../conn/conndb.inc"?>

<?php
$username
=$_POST['username'];
$sql="SELECT username FROM member WHERE username='$username'"
$result mysql_query($sql) or die('Query failed. ' mysql_error()); 
//jumpa username yg sama
if (mysql_num_rows($result) == 1) {

$salutation=$_POST['salutation'];
$name=$_POST['name'];
$nationality=$_POST['nationality'];
$address=$_POST['address'];
$postal_code=$_POST['postal_code'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$contactNo=$_POST['contactNo'];
$faxNo=$_POST['faxNo'];
$email=$_POST['email'];
$organization=$_POST['organization'];
$website=$_POST['website'];
$position=$_POST['position'];

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="frm" method="post" action="index.php?menu=registerMember">
<table align="center" width="100%">
    <tr>
        <td align="center" height="150"><b>Username already exist. Choose other</b></td>
    </tr>
    <tr>
        <td>
            <input type="hidden" name="salutation" value="<?php echo $salutation?>">
            <input type="hidden" name="name" value="<?php echo $name?>">
            <input type="hidden" name="nationality" value="<?php echo $nationality?>">
            <input type="hidden" name="address" value="<?php echo $address?>">
            <input type="hidden" name="postal_code" value="<?php echo $postal_code?>">
            <input type="hidden" name="city" value="<?php echo $city?>">
            <input type="hidden" name="state" value="<?php echo $state?>">
            <input type="hidden" name="country" value="<?php echo $country?>">
            <input type="hidden" name="contactNo" value="<?php echo $contactNo?>">
            <input type="hidden" name="faxNo" value="<?php echo $faxNo?>">
            <input type="hidden" name="email" value="<?php echo $email?>">
            <input type="hidden" name="organization" value="<?php echo $organization?>">
            <input type="hidden" name="website" value="<?php echo $website?>">
            <input type="hidden" name="position" value="<?php echo $position?>">
            
        </td>
    </tr>
    <tr>
        <td align="center"><input type="submit" name="submit" value="- OK -"></td>
    </tr>
    <tr>
        <td><br><br></td>
    </tr>
</table></form>
</body>
</html>
<?//    header("Location: ../frontpage/index.php?menu=signin&action=username");
    
exit;
} else 
// check username & password

{
//generating password
# all the chars we want to use 
        
$length=8;
        
$all=explode(" "
         
"a b c d e f g h i j k l m n o p q r s t u v w x y z " 
        
"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z " 
        
"0 1 2 3 4 5 6 7 8 9"); 
        for(
$i=0;$i<$length;$i++) { 
            
srand((double)microtime()*1000000); 
            
$randy=rand(061); 
            
$pass.=$all[$randy]; 
        }
    
//print "$pass";
    //print "<br> Generating password compelete";
//end generate password
$salutation=$_POST['salutation'];
$name=$_POST['name'];
$nationality=$_POST['nationality'];
$address=$_POST['address'];
$postal_code=$_POST['postal_code'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$contactNo=$_POST['contactNo'];
$faxNo=$_POST['faxNo'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$pass;
$organization=$_POST['organization'];
$website=$_POST['website'];
$position=$_POST['position'];
$status1='TRUE';
/*mysql_select_db ("irrdb");*/
mysql_query("INSERT INTO member (salutation, name, nationality, address, postal_code, city, state, country, contactNo, faxNo, email, username, password, organization, website, position, status)
VALUES ('
$salutation','$name','$nationality','$address','$postal_code','$city','$state','$country','$contactNo', '$faxNo','$email','$username','$password','$organization','$website','$position','$status1')");  

$to $email;
$subject "Welcome to IRRDB Website";
$message "Congratulations! Your registration has been successful. \n";
$message $message.''."\n";
$message $message.''."Your username is : $username \n";
$message $message.''."Your password is : $pass \n";
$message $message.''."\n";
$message $message.''."Thank you for registering with IRRDB Website";
$from "irrdb@streamyx.com";
$headers "From: $from";
mail($to,$subject,$message,$headers);
//echo "Mail Sent.";

//mysql_close();
?>
<html>
<head>
<meta http-equiv="Refresh" content="3;url=index.php">
</head>
<body>
<table align="center">
    <tr>
        <td align="center"><b>Successfully registered. Your password will be sent to your email </b></td>
    </tr>
</table>

</body>
</html>

<?
}
?>