Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 05-07-2004, 12:39 PM   #1 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
updating every row with random password script

Hey. Im trying to get a lot of a membership script finished, and theres a few things still need doing. This part im having problems with. Ive imported 750 records from a CSV file to an SQL database. These records hae been assigned random usernames and passwords. However, the passwords need to be MD5'd. So what I need to do is add an md5'd password to every user in the database, and email each individual their own password (the non-md5 one). The problems im haing is that i can never get it to work properly. It either updates everyone with the exact same password, or it updates 1 person, or it doesnt do anything. Please help!
I need some sort of loop to run the update query in, make any random password, add the password in MD5 form to the first record, email the non md5 password to that records email, and repeat the loop for the next record, producing a new unique password. The records dont have any type of auto_increment ID, so it will need to be done some other way. Any ideas?
I currently have the following, but theres no loop or anything to add a unique password to eeach record in the table
[code:1:d67bcc65a1]
<?php
include("database.php");
$randpass= rand();
$query = "UPDATE users SET password = md5('$randpass') "
$query2 = "SELECT * FROM users";
$result = mysql_query($query) or die(mysql_error());
$result2 = mysql_query($query2) or die(mysql_error());
while ($row = mysql_fetch_array($result2)) {
mail($row["email"],"password $pass username $username)
}
?>
[/code:1:d67bcc65a1]
That code updates every record with the same password. i need it to update every record in turn with an individual password, and email that person right after it updates with their non-md5'd password.
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-07-2004, 12:46 PM   #2 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Take this
$randpass = rand();
$query = "UPDATE users SET password = md5('$randpass')";
and place into the while statement.
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-07-2004, 02:44 PM   #3 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
But i want a different random password to be placed in every row of the table
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-07-2004, 08:27 PM   #4 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Yep. Everytime it loops <b>while</b> there are still results it will reset the $randpass variable. Whats between { } after while, gets done for each new result.
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-08-2004, 11:35 AM   #5 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
[code:1:9acd7105f5]
<?php
include("database.php");

$query2 = "SELECT * FROM users";

$result2 = mysql_query($query2) or die(mysql_error());
while ($row = mysql_fetch_array($result2)) {
$randpass= rand();
$query = "UPDATE users SET password = md5('$randpass')";
$result = mysql_query($query) or die(mysql_error());
/*mail code goes here*/
echo $row["email"] . "<BR>Username: " . $row["username"] . "<BR>Password: " . $randpass . "<BR><BR>";
}

?>
[/code:1:9acd7105f5]

I did that. In the echo bit at the end, its fine, it echo's a different random password for eceryone. However, the update query has updated everyone with the same md5 password.
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-08-2004, 11:59 AM   #6 (permalink)
Possible Terrorist
 
kwvarga's Avatar
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
iTrader: 0 / 0%
Latest Blog:
A+ Certification

kwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web pro
Send a message via AIM to kwvarga
use this

[code]<?php
include("database.php");

$query2 = "SELECT * FROM users";

$result2 = mysql_query($query2) or die(mysql_error());
while ($row = mysql_fetch_array($result2)) {
$randpass= rand();
$user = $row['username'];
$query = "UPDATE users SET password = md5('$randpass') WHERE username = '$user'";
$result = mysql_query($query) or die(mysql_error());
/*mail code goes here*/
echo $row["email"] . "<BR>Username: " . $row["username"] . "<BR>Password: " . $randpass . "<BR><BR>";
}

?>
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
kwvarga is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-08-2004, 12:02 PM   #7 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
Thank alot for the quick reply Spear, Im trying to get this done ASAP. Ill try that code now
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-08-2004, 12:07 PM   #8 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
It works :-) Thanks man
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

vB 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
Need help for random banner rotator script googlesuccess Coding Forum 2 11-17-2006 01:22 PM
Random Link Script tosaha Coding Forum 7 08-22-2006 01:08 PM
random image script Julie Coding Forum 1 03-06-2006 04:20 PM
I need a random script wbstein Coding Forum 6 06-16-2004 11:16 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:11 PM.
© Copyright 2008 V7 Inc