devil420 Posted February 27, 2011 Share Posted February 27, 2011 I'm using this type of code below. how can my site may have access to my e-mail ? and how can I send e-mails containing passwords to users.?? Plz help. //code is like this// if($_POST['submit']=='Register') { // If the Register form has been submitted $err = array(); if(strlen($_POST['username'])<4 || strlen($_POST['username'])>32) { $err[]='Your username must be between 3 and 32 characters!'; } if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username'])) { $err[]='Your username contains invalid characters!'; } if(!checkEmail($_POST['email'])) { $err[]='Your email is not valid!'; } if(!count($err)) { // If there are no errors $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 tz_members(usr,pass,email,regIP,dt) VALUES( '".$_POST['username']."', '".md5($pass)."', '".$_POST['email']."', '".$_SERVER['REMOTE_ADDR']."', NOW() )"); if(mysql_affected_rows($link)==1) { send_mail( '[email protected]', $_POST['email'], 'sitename - 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: demo.php"); exit; } //but while running it on local server it shows the message "failure" as I have mentioned in the index.php. Plz provite a template codeing to solve the problem// Link to comment https://forums.phpfreaks.com/topic/229034-how-can-i-send-randomly-genarated-password-to-registered-users-via-my-email/ Share on other sites More sharing options...
phpfreak Posted February 27, 2011 Share Posted February 27, 2011 Have you tried just using the mail() function instead of send_mail() ? Link to comment https://forums.phpfreaks.com/topic/229034-how-can-i-send-randomly-genarated-password-to-registered-users-via-my-email/#findComment-1180374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.