USERNAME:
PASSWORD:
Save Info!
Logging in…
This topic is 1 page long.
[ Profile | Posts | Contact ]
Posted at: 6/14/06 04:56 AM
Sign-Up: 01/12/03
Posts: 577
Hey guys,
I need some sort of code or program which sets a different password for different users to get to a particular page on my website... I want this to be unique to only them though and they can use it any time they want... Does this requir something really huge or is it simplistic? Please help ASAP!!
Thanks
Posted at: 6/14/06 05:31 AM
Sign-Up: 09/07/03
Posts: 12,131
It can be really simple. :)
<?php
// The characters which will be in the passwor $pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
//The max length of the password $length = 16;
for ($i=0; $i < $length; $i++) { $pass.= $pattern{rand(0,35)}; }
?>
Now $pass has stored a random password which contains 16 characters. Simple, but effective.
NG Review & BBS Moderator // PM Review & BBS Abuse to someone else
Posted at: 6/14/06 05:42 AM
Sign-Up: 07/23/04
Posts: 6,450
<?php $i = 0; while($i <= 12) // Change to pass length { @$pass .= chr(rand(48, 122)); $i++; } ?>
Easy enough, no?
"My software never has bugs. It just develops random features. " - Unknown [ PHP: Main | Omigod, a blog ]
Posted at: 6/14/06 06:17 AM
At 6/14/06 05:31 AM, Zendra wrote: It can be really simple. :) <?php // The characters which will be in the passwor $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; //The max length of the password $length = 16; for ($i=0; $i < $length; $i++) { $pass.= $pattern{rand(0,35)}; } ?> Now $pass has stored a random password which contains 16 characters. Simple, but effective.
Sorry I suck at anything to do with web design, can you tell me how this works and where I have to put it in Dreamweaver? When i put it in the HTML box and preview nothing happens...
Posted at: 6/14/06 06:19 AM
Let me start a fresh... I have a download to a video on a page... When people purchase this download via paypal an e-mail will be sent to me and I will give them the link to the page, but to prevent sharing of the download I need a password system which is specific to each buyer... I am at a loss... Do you understand what I am asking?
Thanks for all your help so far guys! ;)
Posted at: 6/14/06 08:13 AM
Sign-Up: 07/01/03
Posts: 473
At 6/14/06 06:17 AM, Masonogy1 wrote: Sorry I suck at anything to do with web design, can you tell me how this works and where I have to put it in Dreamweaver? When i put it in the HTML box and preview nothing happens...
You'll need to learn some PHP to use this code (not much though but a little bit at least). Basically change your HTML file extension from .htm(l) to .php.
Posted at: 6/14/06 08:14 AM
First you need to be sure that you have PHP installed. If you copy and paste the code at the top of your page and put a tag (<?= $pass ?>) on the HTML code where you want the password to being outputted the randomised code will be put there. Do note you need to re-name your page to the exstensions of PHP (.php) - instead of .html/.htm. So the server can process the code stored in the page.
At 6/14/06 06:19 AM, Masonogy1 wrote: Do you understand what I am asking?
Yes, yes. However, elbekko's code kinda does the same, but since he's using the '@', no password will be shown on the page - hint to elbekko. ;) See what works and what you like.
Posted at: 6/14/06 08:16 AM
I'm using the @ to suppress warnings about vars not being set, I'm not echoing anything =p
Posted at: 6/14/06 08:23 AM
At 6/14/06 08:16 AM, elbekko wrote: I'm using the @ to suppress warnings about vars not being set, I'm not echoing anything =p
Haha, that's a lazy excuse. ;) It needs to be printed and you know that. :)
Posted at: 6/14/06 09:03 AM
You can always echo the pass... :D But preferably mail it I guess.
Posted at: 6/14/06 10:29 AM
At 6/14/06 09:03 AM, elbekko wrote: You can always echo the pass... :D
Not if you're using '@'! ;)
:But preferably mail it I guess.
Yap, that would be a good idea, rather than print it on the screen. Though you have to remove the '@' if you want the password being visible. :)
All times are Eastern Standard Time (GMT -5) | Current Time: 07:57 AM
<< Back