Need help with register/login script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mainsailcom
Forum Newbie
Posts: 8
Joined: Sun Oct 09, 2011 11:09 am

Need help with register/login script

Post by mainsailcom »

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('admin@yourdomain.com',
$_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('<br />',$err);
}

header("Location: sdlogin3.php");
exit;
}


?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Need help with register/login script

Post by Celauran »

Code: Select all

if(mysql_affected_rows($link)==1)
{
send_mail('admin@yourdomain.com',
$_POST['email'],
'Registration System - Your New Password',
"Your username is: {$_POST['username']}\r\nYour password is: {$pass}");
etc.
mainsailcom
Forum Newbie
Posts: 8
Joined: Sun Oct 09, 2011 11:09 am

Re: Need help with register/login script

Post by mainsailcom »

Celuran:

No joy...adding the additional code still returns the new password but does not
include the username
mainsailcom
Forum Newbie
Posts: 8
Joined: Sun Oct 09, 2011 11:09 am

Re: Need help with register/login script

Post by mainsailcom »

Celuran:

My apologies..your code works fine, I had a gremlin elsewhere.
All fine now, Thanks for the help
Post Reply