Try to use this important htaccess code for redirecting an URL's index page to non index Url’s. this code is very very important for seo point of view
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^/?index\.html$ http://www.maindomain.com/$1 [R=301,L]
Tuesday, 6 August 2013
Redirect URL's index page to nonindex page
Redirect URL from subdirectory to sub domain using htaccess
We can redirect URL's from any subdirectory (like maindomain.com/dorectoryname) to a sub domain (subdomain.maindomain.com) using PHP and .htaccess by the subsequent ways.
For example, the .htaccess file is full of rules like the following:
For example, the .htaccess file is full of rules like the following:
------------------------------------------------------------------------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$
RewriteRule ^dorectoryname/(.*)$
http://subdomain.maindomain.com/$1 [L,QSA,R=301]
or we can using this code
RewriteCond %{REQUEST_URI} ^/dorectoryname
RewriteRule ^(.*)$ http://subdomain.maindomain.com/$1 [R=301,L,P]
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.
http://xyz.com/activate.php?key=true&p=fgdsfdjhfyuiobmjioujnllshgfuropvn
Make a page named it as activate.php and paste below stated php code
This is a link, which comes from user email, when the user click on itt, then the link goes and redirect to this script.
http://xyz.com/activate.php?key=true&p=fgdsfdjhfyuiobmjioujnllshgfuropvn
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());
if($result)
{
$_SESSION['PROCESS'] = $lang['Account_activated'];
header("Location: ../index.php");
}
else
{
$_SESSION['ERROR'] = $lang['Key_error'];
header("Location: ../index.php");
}
}
else
{
$_SESSION['ERROR'] = $lang['Invalid_key'];
header("Location: ../index.php");
}
{
$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());
if($result)
{
$_SESSION['PROCESS'] = $lang['Account_activated'];
header("Location: ../index.php");
}
else
{
$_SESSION['ERROR'] = $lang['Key_error'];
header("Location: ../index.php");
}
}
else
{
$_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
$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.
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
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, ......) {
statements1;
statements2;
}
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
Example
<?php
function xyz()
{
----
-----
}
?>
the basic syntax
function <function name>($arguments1, $arguments2, ......) {
statements1;
statements2;
}
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
Example
<?php
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
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
<?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 ="http://www.yoursite.com/ccavenue_returndata.php";
$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="http://www.example.com/images/loader.gif" 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="https://www.ccavenue.com/shopzone/cc_details.jsp">
<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="test_test@yahoo.com"> <!--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" />
</form>
<?php
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" ;
else
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:
Code:
<?php
$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;
$t++;
}
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.
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:
Code:
<?php
$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;
$t++;
}
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>
</select>
<input name="submit" type="submit" value="Send" />
</form>
<?php
function comma($arr){
$length=count($arr);
if($length>=1)
{
$i=0;
foreach($arr as $key=>$value)
{
$i++ ;
if($i!=$length)
$itemid=$itemid.''.$value.', ';
if($i==$length)
$itemid=$itemid.''.$value;
}
}
return $itemid;
}
if(isset($_POST['submit'])){
if($_POST['test']!=''){
//sort($_POST['test']);
$country=comma($_POST['test']);
echo $country;
}
}
?>
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>
</select>
<input name="submit" type="submit" value="Send" />
</form>
<?php
function comma($arr){
$length=count($arr);
if($length>=1)
{
$i=0;
foreach($arr as $key=>$value)
{
$i++ ;
if($i!=$length)
$itemid=$itemid.''.$value.', ';
if($i==$length)
$itemid=$itemid.''.$value;
}
}
return $itemid;
}
if(isset($_POST['submit'])){
if($_POST['test']!=''){
//sort($_POST['test']);
$country=comma($_POST['test']);
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";
code is:
print "Hello World";
or echo "Hello";
Thursday, 25 August 2011
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 Vs PHP Require
PHP Include Vs PHP Require
Subscribe to:
Posts (Atom)

