Good day guys. Anyone can tell me how to send to email a random password when they register? Thanks

$random_number = rand(5000000000,9000000000);
$rform .= "Your Password:<br/><input type=\"hidden\" name=\"pwd\" value=\"$random_number\"/><br/>";
$rform .= "Retype Password:<br/><input type=\"hidden\" name=\"cpw\ value=\"$random_number\"/><br/>";
$gen_pass = rand(11111,99999);
// remove the password input field in your registration form.
// inserting in ur sql
password='".$gen_pass."'
// mail it
$message = "Helo, this is your password: .$gen_pass.";
$check = mail("abc@example.com", $message, "Registration@mysite.com");
if($check){
echo "Mail sent!";}
$time = time();
$pass = md5($time);
$newpass= substr($pass,0,6);
////send password to user email using phpmail
$msg = "Your password: ".$newpass."";
$subj = "Registration detailss";
$headers = 'xdos' . "\r\n" .
'Reply-To: jhunwap@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, $subj, $msg, $headers);
///now insert/ update the password of the user
if($tolog)
{
$time = time();
$pass = md5($time);
$newpass= substr($pass,0,6);
$msg = "\n Username: ".$uid." \n Password: ".$newpass." \n Security Answer: ".$answer." \n\n Welcome! \n\n haha is a nice friendly chat community that offers lot of exciting and new features. We are glad to have you with us! \n Please feel free to invite your friends along. \n\n Follow the link below to login into your account directly \n http://haha.info/in.php?u=".$uid."&p=".$newpass." \n\n Best Regards, \n Keep";
$subj = "Registration Details";
$headers = 'From: noreply@site' . "\r\n" .
'Reply-To: [email]wah@gmail.com[/email]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, $subj, $msg, $headers);
}else{
echo "<a href=\"index.php\">";
echo "Home</a>";
}
$time = time();
$pass = md5($time);
$newpass= substr($pass,0,6);
mysql_query("INSERT INTO r0bz_r0b_users SET BALA, BLA, BLA pass='".$newpass."' ");
Comment