Scripting

PHP script to generate a random string of AplhaNumeric values of given length

Posted on

Script: <?php function generateRandomString($length = 64) {     $characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;     $randomString = ”;     for ($i = 0; $i < $length; $i++) {         $randomString .= $characters[rand(0, strlen($characters) – 1)];     }     return $randomString; } echo generateRandomString(); ?>   Output: < p> Advertisements

Advertisements
Scripting

Integrating PHP into HTML Form pages.

Posted on

The login pages of a web site are usually HTML forms. The HTML forms will be linked to a script to process the data received via form from the user.   This linking is performed by HTM Form Attribute called  “Action” (HTML <form> action Attribute).  Syntax:  <form action="<scriptname>" method="<post/get>"> Example: Save below content as “Form-Example.php” <form action="login.php" method="post">   First name: <input type="text" name="fname"><br>   Last name: <input type="text" name="lname"><br>   <input type="submit" value="Submit"> </form> The page would look like below form for the end user:   Upon user clicks “Submit” button the respective login.php script gets invoked.  Let’s say you’ve […]

Scripting

Installing, Configuring PHP and Running PHP scripts

Posted on

In order to run PHP on your Windows system, you can simply have the required version of regular or debug PHP zip files and extract them.  And then ensure that extracted location is in %PATH% so that Windows starts picking up that particular version of php by defult for running .php scripts/files locally. Example: On the same system you can run multiple versions of PHP side-by-side. C:>php -v PHP 5.3.24 (cli) (built: Apr 10 2013 18:32:42) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies C:>php-5.5.6php.exe -v PHP 5.5.6 (cli) (built: Nov 12 2013 11:35:48) […]