php Random Password Generator

php-sniplets No Comments »

Random Password Generator (based on word list)

This is a random password generator that creates understandable passwords supported word lists. I have just
enclosed a three entry world list since you had better selected a list based on your password requisites and your
users. Whenever you want to get passwords that are fourteen characters long, you’ll require different list than
if you are getting in eight character passwords. And dependant on your users, you may prefer to apply certain
lists. The list I use is almost 4000 words that are 5-7 characters long, all known words that have accepted
potentially offensive content removed. For security grounds I do not want to let in this list.

A mention on security: although this returns relatively solid passwords for the ordinary user, they’re particularly
subject to brute-force attempts. This is even more a matter if someway your word list finds compromised. I’d
not recommend applying this function for anything where an extremely secure password is required.

A mention on selecting your list: you will as well see that I have improved the system to avoid returning
passwords with zeros and ones in them. This is because zero and capital “o” can be mixed-up equally can one,
lowercase “L” and uppercase “i.” When selecting my word list I was as well certain to clean away all words that
begin on the letter “i” or “o” (to keep the optional ucfirst() from making 0 / O and 1 / I mix-up) and words that
carry the letter “L” (to keep l/1 mix-up). I feel that this greatly helps on preventing mix-up, but once more
breaks the protection of the passwords a few. It is your option.

function generatePassword($maxLen = 8)
$words = array(‘alaska’, ‘aline’, ‘alone’,); // Use your personal list here!!!

while (strlen($word) > $maxLen || !$word) $word = $words[array_rand($words, 1)];
if (rand(0,1)) $word = ucfirst($word);
for ($i = 0; $i < $maxLen – strlen($word); $i++) rand(0,1) ? $opener .= rand(2,9) : $closer .=

return “{$opener}{$word}{$closer}”;

for ($i = 0; $i < 20; $i++)
echo generatePassword() . ” “;


Produces: 6Aline43 79Aline7 aline4 2Aline85 58alaska5 59Aline3 4aline Aline3 6alaska44 3Alone Aline587 Aline994
8Aline56 Aline259 699aline 4Aline88 alone3 alone3 Alaska322 267Alaska

use of php mail function

php-sniplets No Comments »

PHP supplies a function named mail that sends email from your script.

The format is as follows: mail(headers,address,message,subject);

These are the values you need to fill in:

address: The e-mail address that receives the message
subject: A string that goes on the subject line of the e-mail message
message: The content that comes in the e-mail message
headers: A string that sets values for e-mail headers

You may set and send an email message as follows:

$to = “”;
$subj = “Testing”;
$mess = “Testing the mail function”;
$headers =\r\n
$mailsend = mail($to,$subj,$mess,$headers);

The message is sent to the address in the $to variable.

You are able to send the message to more than one individual by using the following argument:

$to= “,”;

The $headers string in this case as well sends a blind copy of the message to You will
be able to let in more than one header as follows:

$header = “\r\”;

Headers are optional. Just the first 3 parameters are needed.

The $mailsend variable holds TRUE or FALSE. However, TRUE is no guarantee that the mail will get to wherever
it is going. It just implies that it started out O.K..

Validate an email address with php

php-sniplets No Comments »

This little function with regex is used for Email Address Verification – short and simple, but powerfull, i use it really often. Validating the proper format of an email address is handy, so your users cant type in invalid adresses and you dont have databases full of wrong email adresses.

Email addresses always have a standard format. We can check those with regular expressions:

function validateEmail($email) {
if (!preg_match(“/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/” , $email)) {
return false;
return true;

You can now check your input data:

$email = $_POST['email'];
if (validateEmail($email)) {
} else {
echo ‘false’;

Support for our Products

blog 10 Comments »


The programs in the WebScripts collection are compatible with Perl version 5. (A few are still compatible with version 4, as well, but that shouldn’t really be an issue, since very few servers still offer only Perl 4.) Perl is a reasonably portable language, and can be utilized on pretty much any server. However, as my scripts are designed for UNIX, they may require slight modification before they’ll work on NT or other non-standard servers. Since I’m not familiar with those other servers, I won’t likely be able to answer questions related specifically to them. But posting queries on the support forums will likely find others who are already using the scripts on the server type you’re working with, and who can answer any questions that may arise.


As a general rule, you’re much better off installing any CGI script on your server on your own rather than having someone else do it for you; that way, you’ll know exactly how it works, and know how to modify its configuration if the need arises. Installation of my scripts really isn’t very difficult, and I’ve attempted to provide all the information you need to get the scripts up and running in the documentation and FAQs files. You shouldn’t have any trouble getting any of my scripts running, and of course, the support forums are available if you do run into any problems.

I don’t generally provide “individualized” versions of the scripts, though you are welcome to modify them for your own use in any way you see fit (so long as you don’t redistribute them). If you’re looking for a specific new capability or performance modification, though, by all means, feel free to ask about it. While I probably won’t create a special version of one of the scripts just for you, if the request is likely to be of more general interest, I very well may work it into the next “official” release.


Many questions are addressed in the program documentation files and in the FAQs (Frequently Asked Questions) files. Additional questions, comments, requests and bug reports can of course be posted on one of the support forums.

Link to us

blog No Comments »

Please link to AWSD if you like our free PERL, AJAX and PHP Scripts or free wordpress 2.3 Templates and Themes.

We are always very appreciate of webmasters linking back to AWSD! To link to us, please be so kind to choose and save one of the logos on this page, and link it to – Thanks for your support.

Text Link:
Advanced Web Source Development: AWSD free PERL and PHP scripts, WebLog, Web bulletin board and much more free and usefull code.

Include this code:
Advanced Web Source Development – AWSD <a href=””>free PERL and PHP scripts</a> – WebLog, Web bulletin board and much more free and usefull code.

Banner (please link to

Microbanners (80*15 pixel)

Microbanners (88*31 pixel)

Halfbanner (234*60 pixel)

Fullsize Banner (468*60 pixel)

Impressum Entries RSS Log in