Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 06-14-2009, 12:10 PM   #1 (permalink)
Junior Member
 
dummie84's Avatar
 
Join Date: 04-09-08
Location: Somerset Patriots, USA
Posts: 19
iTrader: 0 / 0%
Latest Blog:
None

dummie84 is liked by many
PHP. Reset/Generate Password - Blank Password

Ok- I've been trying to figure out where to put the generating function in the php file. So far, it is not generating a new password when a user request it. Not sure if the function generateRandpassword is not working or something missing?

1) user type/enter the email address in request form
2) if not found, then stop
3) if found in mysql database email field, then generate a new password
4) update user password field with new password
5) email the new password to the user email address

User get an email like this:
Quote:
************************************************** ********
THIS IS AN AUTOMATED EMAIL - PLEASE DO NOT REPLY.
************************************************** ********


Hi!

You or someone requested for a new password. Here are your seller login infos at sitename.com
Your Username: test123
Your Password:

sitename
http://www.sitename.com

IP Address: xx.xxx.xxx.xx

PHP Code:
<?php
 $email 
mysql_real_escape_string($_POST['email']);
 
$ip=$_SERVER['REMOTE_ADDR'];
 
 if (isset(
$reminder)){
 
$eredm mysql_query("SELECT * FROM `sellers` WHERE memail='$email'") or die(mysql_error());
 if (
mysql_num_rows($eredm)==0){
  print(
"<center><font color=darkred><b>Not found.</b></font></center>");
 } else {
  
extract(mysql_fetch_array($eredm));
  
  
// EXAMPLES: http://www.codemiles.com/php-tutorials/generate-password-using-php-t3120.html
  // http://wiki.jumba.com.au/wiki/PHP_Generate_random_password

  // CREATE RANDOM PASSWORD START
  
function generateRandpassword($size=8$power=0) {
    
$vowels 'aeuy';
    
$randconstant 'bdghjmnpqrstvz';
    if (
$power 1) {
        
$randconstant .= 'BDGHJLMNPQRSTVWXZ';
    }
    if (
$power 2) {
        
$vowels .= "AEUY";
    }
    if (
$power 4) {
        
$randconstant .= '23456789';
    }
    if (
$power 8) {
        
$randconstant .= '@#$%';
    }

    
$newRandpassword '';
    
$alt time() % 2;
    for (
$i 0$i $size$i++) {
        if (
$alt == 1) {
            
$newRandpassword .= $randconstant[(rand() % strlen($randconstant))];
            
$alt 0;
        } else {
            
$newRandpassword .= $vowels[(rand() % strlen($vowels))];
            
$alt 1;
        }
    }
    return 
$newRandpassword;
    
    
$eredm mysql_query("UPDATE sellers SET passwd=('$newRandpassword') WHERE memail='$email'") or die(mysql_error());
    
//return $newRandpassword;
    //return $newRandpassword = mysql_query("UPDATE sellers SET passwd=('$newRandpassword') WHERE memail='$email'") or die(mysql_error());
  //$eredm = mysql_query("UPDATE sellers SET passwd=('$newRandpassword') WHERE memail='$email'") or die(mysql_error());
 
}
  
// CREATE RANDOM PASSWORD END
  
  
$cont="**********************************************************\nTHIS IS AN AUTOMATED EMAIL - PLEASE DO NOT REPLY.\n**********************************************************\n\n\nHi! \n\nYou or someone requested for a new password. Here are your seller login infos at $sitename.com \nYour Username: $userne \nYour Password: $passwd \n\n$sitename \n$siteurl \n\nIP Address: $ip";
  
$headers "From: $sitename <pwd_robot@$sitename.com>\n";
  @
mail($email,"Lost $sitename Seller Account Details.",$cont,$headers);
  print(
"<center><font color=darkgreen><b>An email has been sent.</b></font></center>");
 }
 }
?>
Normally I'd figure out what the problem through trials and errors but I'm lost.
__________________
PHP Programming... PayBannerAd Script... Digital Marketplace Website
dummie84 is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Download pdf with password sniffer Web Usability 3 01-17-2009 07:04 AM
SHA1 PHP Something not right about password dummie84 Coding Forum 3 08-09-2008 11:57 AM
Password Protection Aisne SEO Forum 11 08-11-2006 05:28 PM
[Linux] Reset MySQL Password QT_ Dedicated Servers 0 01-08-2004 08:18 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 12:22 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.