I have a registration/login script (php/mysql) that automatically sends the user the password.
The username is chosen by the registrant, the password is random
I need to modify the script so that the email also includes the selected user name…any help much appreciated.
Partial script as follows…
$pass = substr(md5($_SERVER[‘REMOTE_ADDR’].microtime().rand(1,100000)),0,6);
// Generate a random password
$_POST[‘email’] = mysql_real_escape_string($_POST[‘email’]);
$_POST[‘username’] = mysql_real_escape_string($_POST[‘username’]);
// Escape the input data
mysql_query(" INSERT INTO
tz2_members(company,first,last,address1,address2,city,state,zip,phone,usr,pass,email,regIP,dt)
VALUES(
‘".$_POST[‘company’]."’,
‘".$_POST[‘first’]."’,
‘".$_POST[‘last’]."’,
‘".$_POST[‘address1’]."’,
‘".$_POST[‘address2’]."’,
‘".$_POST[‘city’]."’,
‘".$_POST[‘state’]."’,
‘".$_POST[‘zip’]."’,
‘".$_POST[‘phone’]."’,
‘".$_POST[‘username’]."’,
‘".md5($pass)."’,
‘".$_POST[‘email’]."’,
‘".$_SERVER[‘REMOTE_ADDR’]."’,
NOW()
)");
if(mysql_affected_rows($link)==1)
{
send_mail(‘[email protected]’,
$_POST[‘email’],
‘Registration System - Your New Password’,
'Your password is: '.$pass);
$_SESSION[‘msg’][‘reg-success’]=‘We sent you an email with your new password!’;
}
else $err[]=‘This username is already taken!’;
}
if(count($err))
{
$_SESSION[‘msg’][‘reg-err’] = implode(’
’,$err);
}
header(“Location: sdlogin3.php”);
exit;
}
?>