WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Random Password Generator
Categories : PHP, Strings, Security Click here to Update Your Picture
Sumit Agarwal
Date : Nov 17th 2007
Grade : 3 of 5 (graded 1 times)
Viewed : 1319
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Sumit Agarwal
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

A random password generator. The script can generate passwords of varying complexity. You can specify the maximum and minimum length of the password and the characters that are to be included in the password.

<?php

function random_string($minlength = 6, $maxlength = 6, $uselower = true, $useupper = false, $usenumbers = true, $usespecial = false){
   
$charset = '';
    if (
$useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    if (
$usenumbers) $charset .= "1234567890";
    if (
$usespecial) $charset .= "~@#$%^*()_+-={}|][";
    if (empty(
$charset) || $uselower) $charset .= "abcdefghijklmnopqrstuvwxyz";
   
$length = ($minlength > $maxlength) ? mt_rand ($maxlength, $minlength) : mt_rand ($minlength, $maxlength);
   
$charsetlength = strlen($charset) - 1;
    for (
$i=0; $i<$length; $i++) {
       
$str .= $charset[mt_rand(0, $charsetlength)];
    }
    return
$str;
}
echo
'SIMPLEST : ' . random_string(5, 5, false, false) . "<br>\n";
echo
'SIMPLE : ' . random_string(5, 5, false, true, false) . "<br>\n";
echo
'MEDIUM : ' . random_string() . "<br>\n";
echo
'HARD : ' . random_string(5, 10, true, true, false) . "<br>\n";
echo
'HARDER : ' . random_string(5, 10, true, true) . "<br>\n";
echo
'HARDEST : ' . random_string(5, 10, true, true, true, true) . "<br>\n";
?>



A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
A few functions to create random passwords.
Categories : PHP, Security, Strings
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form
Categories : HTML, PHP, Strings
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
Secure URL $_GET
Categories : PHP, Data Validation, Security
Adding dashes to credit card numbers
Categories : Strings, Credit Cards, PHP
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
Printer friendly pages from anywhere on a website.
Categories : PHP, Strings, Content Management