Sunday, 2 October 2011

How to make account registration with account activation script in PHP

This is a basic and simple user account registration script with account activation script, written in PHP and MySql.

This is a link, which comes from user email, when the user click on itt, then the link goes and redirect to this script.

Make a page named it as activate.php and paste below stated php code
if($_GET['key'] == true)
$key = $_GET['p'];
$sql = "SELECT * FROM users WHERE user_key = '" . $key . "'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_affected_rows($result) > 0)
$sql = "UPDATE users
SET user_key = '', user_active = '1'
WHERE user_key = '" . $key . "'";

$result = mysql_query(sql) or die(mysql_error());

$_SESSION['PROCESS'] = $lang['Account_activated'];
header("Location: ../index.php");
$_SESSION['ERROR'] = $lang['Key_error'];
header("Location: ../index.php");
$_SESSION['ERROR'] = $lang['Invalid_key'];
header("Location: ../index.php");

Thursday, 22 September 2011

How to generate a random password using php

Here there is a simple example for generate a random password using php, it is quite easy and simple to make.

$length =10; // the length of the required password length
$characters_to_use ="abcdef1234567890"; // characters are to be use in your password
for($i = 0; $i < $length; $i++)
$do = mt_rand(0,strlen($characters_to_use)-1);
$password = $password . $characters_to_use{$do};

echo $password; // here you can view the password 

Wednesday, 21 September 2011

Hide navbar from blogger

If you want to hide or remove the navigation bar which is appear on the top region of your blogger, follow these steps

1. Login to your blogger.
2. Click "Designs".
3. Goes to "Template Manager", a template editor will be open.
4. Click on "Advanced" and then "Add css".
5. Then at right side text box areas put the below mentioned css code . and then click on "apply to Blog" option for saving this property to your blogger.

#navbar {
height: 0px;
visibility: hidden;
display: none;

6. Watch the changes in your browser.

Monday, 19 September 2011

php web development tools - captcha

Web development tool  CAPTCHA, stands for Completely Automated Public Turing to tell Computers and Humans Apart.

A CAPTCHA is a program that can generate distorted text  that humans can see or listen but computer cannot. 

Applications of CAPTCHA systems
-- Preventing Spam in Blogs.
-- Protecting Website Registration.
-- Search Engine Bots.
-- Worms and Spam.

In web application development we can use the following CAPTCHA systems that are listed below
reCAPTCHA - In this type of CAPTCHA systems user can view the distorted text or also listen the text, now a days it is most popular CAPTCHA systems for web developers

Securimage  : The Securimage Captcha script is free open-source. here the  PHP script is used to generat complex images and complex CAPTCHA alphanumeric codes.

FreeCap - This script support GPL CAPTCHA script systems to stop spam

Sunday, 18 September 2011

function with static variables

static variables can not be reset
values can not change after execution
can not accessible through out the programme

function with global variables

accesible through program.
it generates a unique value after execution
can not assign any values at the time of declaring it or using it

php functions

means set of instructions
the basic syntax
function <function name>($arguments1, $arguments2, ......) {

It has four parts
-Special word function
-names that u want to give your function name
- function parameters list precided by dollar sign
- function body brace enclosed set of statements


function xyz()

php is HTML embeddedness

Php is embedded within HTML.
 All embeded scripting language don't need to be compiled into binary code before they can be tested or used , just write  and run.
but PHP is interpreted.

PHP is portable (Cross Platform  Compatible)

we can developed on any client OS and then uploaded your  php script to a server on any OS.
Not tag based

Wednesday, 14 September 2011

CCavenue PHP script - Free ccavenue developers code in php

$Merchant_Id = "your_merchantid";//This id(also User Id) available at "Generate Working Key" of "Settings & Options"
$Amount = "amount";//your script should substitute the amount in the quotes provided here
$Order_Id ="orderid";//your script should substitute the order description in the quotes provided here
$WorkingKey = "working_key";//Given to merchant by ccavenue
$Redirect_Url ="";
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value

<p align="center" style="font-family:Calibri; font-size:18px;"><img src="" alt="loader"></p>
<p align="center" style="font-family:Calibri; font-size:24px;color:#3670A7;">Processing to CCAvenue..............</p>
<form id="form2" method="post" action="">
<input type=hidden name="Merchant_Id" value="<?php echo $Merchant_Id; ?>">
<input type="hidden" name="Amount" value="<?php echo $Amount; ?>">
<input type="hidden" name="Order_Id" value="<?php echo $Order_Id; ?>">
<input type="hidden" name="Redirect_Url" value="<?php echo $Redirect_Url; ?>">
<input type="hidden" name="Checksum" value="<?php echo $Checksum; ?>">
<input type="hidden" name="billing_cust_name" value="yourname"> <!--Pass Customer Full Name -->
<input type="hidden" name="billing_cust_address" value="123 Green Acres,West Eden"><!--Pass Customer Full Address-->
<input type="hidden" name="billing_cust_country" value="India"> <!--Pass Customer Country -->
<input type="hidden" name="billing_cust_state" value="AP"><!--Pass Customer State -->
<input type="hidden" name="billing_cust_city" value="Kakinada"> <!--Pass Customer City -->
<input type="hidden" name="billing_zip" value="533002"> <!--Pass Customer Zip Code-->
<input type="hidden" name="billing_cust_tel" value="9999999999"> <!--Pass Customer Phone No-->
<input type="hidden" name="billing_cust_email" value=""> <!--Pass Customer Email address-->
<input type="hidden" name="delivery_cust_name" value="delivery_name"> <!--Pass Same or other other detail fill by customer-->
<input type="hidden" name="delivery_cust_address" value="123 Green Acres,West Eden">
<input type="hidden" name="delivery_cust_country" value="India">
<input type="hidden" name="delivery_cust_state" value="AP">
<input type="hidden" name="delivery_cust_tel" value="999999999">
<input type="hidden" name="delivery_cust_notes" value="Testing ccav">
<input type="hidden" name="Merchant_Param" value="">
<input type="hidden" name="billing_zip_code" value="533002">
<input type="hidden" name="delivery_cust_city" value="Kakinada">
<input type="hidden" name="delivery_zip_code" value="533002">
<input type="submit" value="Proceed to Buy Now" />

function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
$str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
$adler = 1;
$adler = adler32($adler,$str);
return $adler;

function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
$str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
$adler = 1;
$adler = adler32($adler,$str);
if($adler == $CheckSum)
return "true" ;
return "false" ;

function adler32($adler , $str)
$BASE = 65521 ;
$s1 = $adler & 0xffff ;
$s2 = ($adler >> 16) & 0xffff;
for($i = 0 ; $i < strlen($str) ; $i++)
$s1 = ($s1 + Ord($str[$i])) % $BASE ;
$s2 = ($s2 + $s1) % $BASE ;
//echo "s1 : $s1 <BR> s2 : $s2 <BR>";


return leftshift($s2 , 16) + $s1;

function leftshift($str , $num)
$str = DecBin($str);
for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
$str = "0".$str ;
for($i = 0 ; $i < $num ; $i++)
$str = $str."0";
$str = substr($str , 1 ) ;
//echo "str : $str <BR>";
return cdec($str) ;

function cdec($num)

for ($n = 0 ; $n < strlen($num) ; $n++)
$temp = $num[$n] ;
$dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);

return $dec;

Monday, 5 September 2011

How to upload files int to server using Php?

You should make two pages in WebBuilder: the form page and the processing page. The latter holds the PHP script and will report all successful uploads.

I - The form page
1. Draw a Form Area and change the Form Properties to:
- Action: upload_plus.php
- Method: POST
- Encoding type: multipart/form-data

2. Make up your form. Remarks:
- include one or more File Upload objects and name all of them userfile[]
- include a Push Button and set the Button Type to Submit
- do not include any other form elements.

II - The processing page
1. Make up a nice page according the style of your site. Remarks:
- tell your visitors that the listed files are uploaded succesfully.
- include a link or menu to other pages of your site.

2. Rename the page to upload_plus using the Site Manager.
3. Bring up the Page Properties dialogue and change it to:
- File Extension: php

4. Draw an HTML object.
- The object size should be enough for the list of uploaded files.
- Bring up the HTML Properties dialogue and insert this:

$uploaddir = './uploads/';
$allowed = array('jpg','jpeg','gif','pdf');
$max_size = 1024 * 1024;
# No edits beyond this line

if (isset($_FILES['userfile'])) {
foreach ($_FILES['userfile']['error'] as $i => $error) {
if ($error == 0 && $_FILES['userfile']['size'][$i] <= $max_size) {
$file_ext = pathinfo($_FILES['userfile']['name'][$i],PATHINFO_EXTENSION);
$file_name = basename($_FILES['userfile']['name'][$i],'.'.$file_ext);
if (in_array(strtolower($file_ext),$allowed)) {
$new_base = $_FILES['userfile']['name'][$i];
$t = 1;
while (file_exists($uploaddir.$new_base)) {
$new_base = $file_name.'['.$t.'].'.$file_ext;
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i],$uploaddir.$new_base)) {
chmod($uploaddir.$new_base, 0644);
echo 'Successful upload: '.$_FILES['userfile']['name'][$i].'<br>'."\n";

III - Final steps
1. Publish your site.
2. Create an 'upload directory' named uploads on your server.
- This can be done using the FTP Manager or any other FTP client.
- Be sure this directory is on the same level as the processing page.
- Set the directory's permissions to: 777.

Wednesday, 31 August 2011

Print multi select option with comma in php

Using php we can print or display multiple select option with comma.
Copy this php code and test.
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<select name="test[]" multiple="multiple">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
<input name="submit" type="submit" value="Send" />
function comma($arr){
foreach($arr as $key=>$value)
$i++ ;
$itemid=$itemid.''.$value.', ';
return $itemid;
echo $country;

Monday, 29 August 2011

php print statement

two basic contsructer for printing the outputs are echo and print. It prints only one arguments

code is:
print "Hello World";
or echo "Hello";

Thursday, 25 August 2011

php switch case statement

php switch case statement

PHP If - Else Conditional Statment

PHP If - Else Conditional Statment

PHP if statement is similar to other programming languages

PHP if statement is similar to other programming languages

Difference between require_once and include_once in Php

Difference Between require_once() Vs Include_once() In Php

php include_once

php include_once

PHP - require_once

PHP - require_once

PHP Include Vs PHP Require

PHP Include Vs PHP Require

PHP Require - why we used this?

PHP Require

PHP Includes - why we used this?

PHP Includes

php comment syntax - Look at various types

Look at various types php comment syntax

Operators used in PHP

Operators used in PHP

Use of PHP Strings

Use of PHP Strings

PHP - Outputting text

For outputting text, we can used the PHP command like echo or print

For Example:-

$string = "Hello";
echo $string;
It will give the output on the browser window

PHP - Variables

The way to store information in php program by using a varible
*All variable is preceeded by $ sign.
* Values are assigned with = operator.
*Composed of letters(lower case and upper case), digits(0 to 9) and under score charecters.
first charecters after $ may not be a number.

Types of variables
1. Interger - a whole number without a decimal point
2. Double -  Floating point like 3.141
3. Boolean two possible values
4. Null  special type has one values NULL.
5. String - sequence of charecter
6. Array -  collection of elements
7. Objects -  Instance of classes
8. Resources -  special variables that hold reference external to PHP

Use of php scripts in html

<title>Simple PHP Scripts</title>   
echo "Hi, Manoj";       

What is php ?

Php is a web development language and stands for PHP Hypertext Preprocessor.
PHP is a server side scripting language, which is embeded to HTML. from which we can create dynamic and interactive web pages.

It is fully cross platform means it runs in native or several operting system like unix, windows or on Mac.

Rasmus Lerdorf, a software engineer worked in apache team member is the father of PHP.
First PHP was developed for personal use in 1994 that way he named it as Personel Home Page.In his next version he added the form interpreter, a tool for pesing sql queries.

Zeev  Suraski and Andi gutmans, two Israel programmers developed Zend Engine and PHP3 and PHP4 for server side scripting language.

PHP5 is newly rebuilt object model to bring PHP is object - oriented language  offering support for features such as inheritance, polymorphism, encapsulation, interfaces, private members and methods and other standard of oop construction.

PHP is open source , Free software and free GPL(General Public Licenses)

Tuesday, 23 August 2011

PHPtutorials4all Basics

PHPtutorials4all provides information for making dynamic and interactive Web pages.
Related Posts Plugin for WordPress, Blogger...