December 26, 2015

AngularJs how to sum two dynamic value from text box?



- Please write following function in script file for sum two dynamic value from text box,

angular.module('App').filter('twosum', function() {
  return function(items) {
    var sum = 0;
    items.forEach(function(item) {
      if (item.item_count) {
         sum += item.item_count;    
      }
    })
    return sum;
  }
})

- In HTML/PHP file where you want to display above sum value write below short code,

<span>{{ table.fields | twosum }}</span>

Enjoy!

December 23, 2015

PHP - When submit form string replace space to Â



Today I working on a PHP project and I face one spacing problem like when I submit form with CKeditor then all space &nbsp; replace with  undefined character,

So I find a best solution for that and share it here.

Fist please include following meta line in <head> tag:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

And second thing is when you submit CKeditor field then used 'utf8_decode' function, see in below example:

$message=utf8_decode($_REQUEST['message']);

Here 'message' is your field name.

Enjoy!

December 21, 2015

How to disable click in AngularJS?




Here is a simple example for disable click in AngularJS,

<body ng-app="ngToggle">
    <div ng-controller="AppCtrl">
        <button ng-click="disableClick(1)">Disable ng-click</button>
    </div>
</body>

In JS:

angular.module('ngToggle', [])
    .controller('AppCtrl',['$scope', function($scope){
    $scope.flag = 0;
    $scope.disableClick = function(n) {
        if (n && n !== $scope.flag) {
            $scope.flag = n;
            alert("Clicked!");
        }
        return false;
    }
}]);




DEMO


Enjoy!

December 15, 2015

PHP - SQL select query return array with used ID field as a key


                                               



In SQL select query while loop you can used ID fields as array key, it's simple. Here is example for that:

<?php
$selRes=mysql_query("SELECT id, name FROM TableName order by id DESC";
if(mysql_affected_rows()>0)
{
$data=array();
while($rowSale=mysql_fetch_array($selRes))
{
    $data[$row[0]] = $rowSale[1];
}
}

//Output
print_r($data);
array([1]=>'name1',[2]=>'name2',[3]=>'name3');

?>

Enjoy!

December 13, 2015

Magento - How to add static page link to main menu?

- Hello friends finally I find the solution for add static page link to main menu in magento CMS,

- First find the top.phtml file from this page: app/design/frontend/default/YourThemeName/template/catalog/navigation/top.phtml

- Before do any changes on this file please take copy of orignal top.phtml file,

- Below is default code of top.phtml file:


<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
       <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- You shoud modified as per below example where I add Home link:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- Or you should also add and magento block shord code (In block you define static menu link in <ul><li> format):

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('navbar_links')->toHtml() ?>  
   </ul>
</div>
<?php endif ?>

- In above example 'navbar_links' is block identifier name.


Enjoy!

December 11, 2015

Ajax concat FormData form + parameters


For Ajax FormData add extra parameters to pass data in PHP file,

See below example for that,

var fd = new FormData(document.getElementById("form"));
fd.append("CustomField", "This is some extra data");
$.ajax({
  url: "stash.php",
  type: "POST",
  data: fd,
  processData: false,  // tell jQuery not to process the data
  contentType: false   // tell jQuery not to set contentType
});

Enjoy!

Multiple ckeditor used on one page with AngularJS.



Yes, its possible to used multiple ckeditor on one page with AngularJs, please see below example OR see here

app.directive('ckEditor', [function () {
    return {
        require: '?ngModel',
        link: function ($scope, elm, attr, ngModel) {

            var ck = CKEDITOR.replace(elm[0]);

            ck.on('pasteState', function () {
                $scope.$apply(function () {
                    ngModel.$setViewValue(ck.getData());
                });
            });

            ngModel.$render = function (value) {
                ck.setData(ngModel.$modelValue);
            };
        }
    };
}])

Enjoy!

November 24, 2015

jQuery validation for price field.

Please follow example for set jquery validation for price field.

HTML
<input id="price" maxlength="7" type="text" />

Javascript
$("#price").on("keyup", function(){
    var valid = /^\d{0,4}(\.\d{0,2})?$/.test(this.value),
        val = this.value;
   
    if(!valid){
        console.log("Invalid input!");
        this.value = val.substring(0, val.length - 1);
    }
});

Enjoy!

OpenCart how to add new menu?



Follow the below step:

Log into your OpenCart administration panel like: domainname.com/admin.

Navigate to Catalog -> Information.

Click the Insert button to add a new content page.

And you can enter page name, description and all others fields.


Select the Data tab. Here you can define page keywords, set Sort Order...etc

Save it.

You need to edit the code of the header.tpl

The file is located in the /catalog/view/theme/yourtheme/template/common/header.tpl folder.

Enjoy!

November 6, 2015

About AngularJS.



Finally now I start work on AngularJS. I like this javascript Framework.

AngularJS is open source, completely free to used. For use of AngularJS you need just basic knowledge of javascript, Ajax and HTML.

Here I display basic example of AngularJS:

<!doctype html>
<html ng-app>
 
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
   </head>
 
   <body>
      <div>
         <label>My Name:</label>
         <input type = "text" ng-model = "MyName" placeholder = "Enter a name here">
         <hr />
       
         <h1>Hello {{MyName}}!</h1>
      </div>
     
   </body>
</html>

Enjoy!

October 28, 2015

jQuery - Validation set custom message.



Add this code in a separate script included after the validation plugin to override the messages:

jQuery.extend(jQuery.validator.messages, {
    required: "This field is required.",
    remote: "Please fix this field.",
    email: "Please enter a valid email address.",
    url: "Please enter a valid URL.",
    date: "Please enter a valid date.",
    dateISO: "Please enter a valid date (ISO).",
    number: "Please enter a valid number.",
    digits: "Please enter only digits.",
    creditcard: "Please enter a valid credit card number.",
    equalTo: "Please enter the same value again.",
    accept: "Please enter a value with a valid extension.",
    maxlength: jQuery.validator.format("Please enter no more than {0} characters."),
    minlength: jQuery.validator.format("Please enter at least {0} characters."),
    rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
    range: jQuery.validator.format("Please enter a value between {0} and {1}."),
    max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
    min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
});

For more read see <a href="http://stackoverflow.com/questions/2457032/jquery-validation-change-default-error-message" target='_blank'>Here:</a>

Enjoy!





October 23, 2015

PHP - Dynamic IP block script.



Please enter the following script in header file of your site which call in all pages for e.g. header.php file,

And also define IP addressed which you want to redirect to another page/link,

Example

<?php $blacklist = array("111.222.333", "444.555.666", "777.888.999");

if(in_array($_SERVER['REMOTE_ADDR'], $blacklist)) {

header("Location: http://sitename.com/404");

exit();
} ?>

Enjoy!

October 15, 2015

Magento - The PDO extension is required for this adapter but the extension is not loaded.



When I upload site live from my local server and getting such kind of error that the PDO extension is required for this adapter but the extension is not loaded.

So I think that the pdo.so php extension must be required in server. And first check in php.ini file If you have access of that file.

;extension=pdo_mysql.so

Please uncomment the above line to activate it

extension=pdo_mysql.so

Save the file and restart the server.


If you have no access of the php.ini file, follow the following steps

Step 1. Please check your Magento installation directory there must me a file named as php.ini.sample.

Step 2. Now rename the file from php.ini.sample to php.ini

Step 3. Put the below code into it

extension = pdo.so
extension = pdo_sqlite.so
extension = sqlite.so
extension = pdo_mysql.so

Step 4. Now refresh your browser cache and the problem has been solved.


Enjoy!

Magento - 1050 Table 'adminnotification_inbox' already exists.




Oho, I already face this type of bug in past,

Here I post solution of this bug: Please check in you database


Drop Table if exists 'adminnotification_inbox'

When you drop this table then magento again create this default new table,

Enjoy!

September 30, 2015

Magento - static block display on col right sidebar.


- If you want to display static block in any page then you can add below code in page.xml file OR you can create your own local.xml file and put this code in that file.

<layout version="0.1.0">
  <default>
    <reference name="right">
      <block type="your/type" template="path/to/your/template.phtml" />
    </reference>
  </default>
</layout>


If you have any questions please comment me, I help you.

Enjoy!

September 25, 2015

jQuery how can remove comma from end of string.



Please see my below example for remove comma from end of string in jQuery.

var edited = test.replace(/^,|,$/g,'');

Enjoy!

How to download script from jsfiddle site?



Yes its possible to view source code of jsfiddle siet.

http://stackoverflow.com/questions/9851878/is-there-a-download-function-in-jsfiddle

Enjoy!

September 11, 2015

How to change page title in Magento?



If you want to change page title from admin side then please follow below steps:


* Login in admin and open CMS > Static pages, then edit page which you want to change "Page Title".

* In frontend and any module, you can use xml file to set new title for your page. The syntax is:

<reference name=“header”>
    <action method=“setTitle” translate=“title”><title>Your Title Here!</title></action>
</reference>

Enjoy!

PHP send email and when click on any link of that email than how to track.



Following is example for track email viewed OR not?

<?php
$user_id = $_GET['user_id'];

If ( $user_id )
{
    $FileName = $id.".txt";
    $ourFileHandle = fopen($FileName, 'w') or die("can't open file");
    fclose($ourFileHandle);
}
else
{
    $to = "jhon@gmail.com"; //to address

    $subject ="Read Receipt Email";

    $message = "Testing whether the read receipt script works or not";
    $message = "<img src=\"http://www.example.com/email.php?user_id=".$to." width=\"0\" height=\"0\" >";
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: kelly@ymail.com' . "\r\n";

    if (mail($to, $subject, $message, $headers) )
    {
        echo "Mail sent successfully";
    }
    else
    {
        echo "failed to send mail";
    }
}

?>

Enjoy!

September 1, 2015

NEWSLETTER SUBSCRIBE CODE MOVE AT FOOTER IN MAGENTO



First you can create a block on the fly and position it precisely in your template files with one line of code:

Add this code: 

<?php echo $this->getLayout()->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe.phtml')->toHtml(); ?>


Enjoy!

August 25, 2015

Magento Please enter a valid URL. Protocol is required (http://, https:// or ftp://)



Please follow the below step for SOLUTION:

1. Open \app\design\install\default\default\template\install\config.phtml

2. Find the textbox where the base url is entered. It will be around line no 85 with name ‘config[unsecure_base_url]‘

3. Remove ‘validate-url’ from its class and save the file.



4. Now you can continue follow the installation.

Enjoy!

How to display Indian Rs. symbol in Magento?




Please follow the below step:

1. Add below code in root.xml

path of file: lib/Zend/Locale/Data/root.xml

Open root.xml file and find below code in that file

<currency type=”INR”>

replace next line with this below code

<symbol>Rs. </symbol>

Enjoy!

August 16, 2015

javascript validation for radio button in php.

<input type='radio' class='w1' name='w1' value='1'>1<br>
<input type='radio' class='w1' name='w1' value='2'>2<br>
<input type='radio' class='w1' name='w1' value='3'>3<br>

<script>
if ( $(':radio[class=w1]').attr('checked') != 'checked' ) {
    alert('Radio not checked');
}
</script>

Enjoy!

php how to get all files name from folder?


<?php
$insArr=array();
if ($handle = opendir('here is folder path name')) {
while (false !== ($file = readdir($handle)))
{
echo $file;
echo '<br>';
}
closedir($handle);}
?>

Its display name of all file/images from specific folder/directory,

Just change the folder/directory name what ever you want, and if you want any help then comment here!

Enjoy!

August 4, 2015

How to reorder billing fields in WooCommerce Checkout template?


Yes its possible using the some change in functions.php file,

Please do the following some change in woocommerce_form_field() function,


There is one below function:

<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>

Please replace with this:

<?php
$mybillingfields=array(
    "billing_first_name",
    "billing_last_name",
    "billing_company",
    "billing_address_1",
    "billing_address_2",
    "billing_city",
    "billing_state",
    "billing_postcode",
    "billing_country",
    "billing_email",
    "billing_phone",
);
foreach ($mybillingfields as $key) : ?>
<?php woocommerce_form_field( $key, $checkout->checkout_fields['billing'][$key], $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>

You can change position of each fields what ever you want.

Enjoy!

July 28, 2015

How to open a browse any file dialog when click on link using javascript?

- Is there any way to open browse file window open when I click on any <a href> link? Please help me for that I have issue in a site and I want some help!

July 18, 2015

How to change date format (MM/DD/YY) to (YYYY-MM-DD) in date picker?

Use the dateFormat function for that:

Example:
$(function(){
$("#to").datepicker({ dateFormat: 'yy-mm-dd' });
$("#from").datepicker({ dateFormat: 'yy-mm-dd' }).bind("change",function(){
var minValue = $(this).val();
minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
minValue.setDate(minValue.getDate()+1);
$("#to").datepicker( "option", "minDate", minValue );
})
});


Demo : http://jsfiddle.net/gaby/WArtA/

Enjoy!

PHP- full calendar how to remove extra slots when week view?


Please do following change in .js file where calendar function call like: calendar.js file:

$('#calendar').fullCalendar({ //re-initialize the calendar
header: h,
        slotMinutes: 30,
});


Enjoy!

jQuery how to append data-tip value when mouse hover?


If you want to set the data attribute with .attr() on mouse hover:

Example
jQuery('li#menu-item-75 a').attr('data-tooltip', 'value');

Demo: http://jsfiddle.net/fkdh8/13/

Enjoy!

July 12, 2015

jQuery ui datepicker set default calendar is a last month

Yes, it's possible using faultDate function:

<?php
$('#selectdate').datepicker({
    defaultDate: '-1m' //Here you can define how many month(s) you want less from current month.
});
?>

Enjoy!

July 8, 2015

PHP - Fedex web service Error:The transaction returned an Error.


Using FedEx web service in PHP. I have developer account in FedEx. It's return following problem of authentication.


Severity: ERROR
Source: prof
Code: 1000
Message: Authentication Failed

Please help to finde out perfect solution.

Thanks in Advance

June 30, 2015

How to remove blank/unnecessary lines in dreamweaver?




This type of issue mostly face when you can download any file from FTP/server, because its Fille Zilla setting issue,
That's why in any .php file lost of blank/unnecessary lines you can see in file when open that file in Dreamweaver,

Here's a helpful solution to remove blank/unnecessary line from file using Dreamweaver:


Step 1: Click CTRL + F

Step 2: Select 'Current Document' from Find In options (if you want replace in all files then select specific folder)

Step 3: checked 'Use regular expression' from footer options

Step 4: Type [\r\n]{2,} in 'Find' text-area

Step 5: Type \n in 'Replace' text-area

Step 6: And press Replace All' button from right side



Enjoy!

June 23, 2015

How to Set a Dynamic Width / Height on Fancybox?


Yes it's possible first you can turn off "autoSize" and then set width as "auto":

$.fancybox.open({
    content  : 'Lorem ipsum dolor sit ame',
    autoSize : false,
    width    : "auto",
    height   : "80%"
});​

To see example <a href="http://jsfiddle.net/2VmrG/" target="_blank">click here!</a>

Enjoy!

June 21, 2015

jquery password validation with at least 8 characters, 1 number, 1 upper and 1 lowercase.


Regular expression offers an extremely powerful way of validation for forms password.

I guess your regular expression should look like:


<form id="register">
    <label for="password">Password:</label>
    <input name="password" id="password" type="password"/>
    <span id="result"></span>
</form>

Here is some javascript/jquery code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#password').keyup(function(){
$('#result').html(checkStrength($('#password').val()))
});

function checkStrength(password)
{
//initial strength
var strength1 = 0;
var strength2 = 0;
var strength3 = 0;
var strength4 = 0;

//length is ok, lets continue.
//if length is 8 characters or more, increase strength value
if (password.length < 8) strength1 = 1;
//if password contains both lower and uppercase characters, increase strength value
if (!password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  strength2 = 1;
//if it has numbers and characters, increase strength value
if (!password.match(/([0-9])/))  strength3 = 1;
//if it has one special character, increase strength value
if (!password.match(/([!,%,&,@,#,$,^,*,?,_,~])/))  strength4 += 1
//if it has two special characters, increase strength value
//if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,",%,&,@,#,$,^,*,?,_,~])/)) strength += 1
//now we have calculated strength value, we can return messages
//if value is less than 2

if(strength1==1)
{
$('#result').text('Password too short.');
} else if(strength2==1) {
$('#result').text('Please used upper & lower case letter.');
} else if(strength3==1) {
$('#result').text('Please used number.');
} else if(strength4==1) {
$('#result').text('Please used any special character.');
} else {
$('#result').text('Strong!');
}
}
});
</script>

Enjoy!

June 18, 2015

MySQL: why does "SELECT count()" return a value of array?




There are two solution to get total number of records from any table, Here are both explain in brief:


First one is - you can used COUNT() directly to select query like below e.g.

$Qr=mysql_query('select COUNT(*) from tablename');
$Qry=mysql_fetch_array($Qr);
echo $Qry;

It's display total number of records.

--------------------------


Second one is - 'mysql_num_rows' like below e.g.

$Qr=mysql_query('select * from tablename');
$Qry=mysql_num_rows($Qr);
echo $Qry;

It's display total number of records.



Enjoy!

June 17, 2015

MySQL select query to COUNT only unique values.



If you used join query on parent table and child table and you want to fetch unique records from both table then see the below example

SELECT COUNT(DISTINCT(t1.id)) FROM table1 t1 left join table2 t2 on t2.id=t1.t2id

Enjoy!

jQuery condition to check responsive screen.


Yes, It's possible to check different media screen in jQuery for add condition.

Following example for different screen:

$(window).resize(function(){
   if ($(window).width() <= 300)
   {
       // do something here
   } else if ($(window).width() <= 800){
     // do something here
   } else if ($(window).width() <= 970){
     // do something here
   } else {
     // do something here for desktop full screen
   }
});

Enjoy!

Javascript validation for radio button.

First write HTML with form and multiple radio fields with same name,

Assign different value for each radio. See in below example.

Also set the form name OR id and form on submit call a function, Below is full example:


<form name="frmAdd" id="frmAdd" onsubmit="return chkRegEvent()" >
  <input type="radio" name="filter" id="filter" value="all" /> View All Evemts
  <input type="radio" name="filter" id="filter" value="upcoming" /> Upcoming Events Only
</form>

In below script check radio button checked OR not?


<script>
function chkRegEvent()
{
    var temp=0;
    for(var i=0; i< document.forms.frmAdd.filter.length;i++)
    {
        if(document.forms.frmAdd.filter[i].checked==true)
        {
            temp=1;
            
        }
        
    }
    if(temp==0)
    {
        alert("Please select filter option.");
        return false;
    }
}
</script>

In alert you should set any message you want.

Enjoy!

June 16, 2015

PHP: Convert text file into XML.

Here is perfect example to convert text file into XML.

abc.txt file content is:

Nokia
Samsung
Micromax

If you want to conver this text file into XML formate like this:

<data>
<mobilestore>Sony</mobilestore>
<mobilestore>Pioneer</mobilestore>
<mobilestore>Boss</mobilestore>
</data>

Solution


First I used file() function for opening the file.

Then used DOMDocument for build the XML structure.

And last file_put_contents() function for saving he result XML file.

If you want exact example then please see here: http://stackoverflow.com/questions/6741251/convert-text-file-contents-to-xml

Enjot!


PHP: how to play all type of vides using tag?


PHP: how to play all type of videos using tag?

The HTML have a <video></video> tag for playing the .mp4 video.


<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  <source src="movie.webm" type="video/webm">
</video>

Now If you have not above three type of video then don't warry.

You shoude convert video in above three (mp4, ogg, webm) formate from here: http://video.online-convert.com/

HTML - Video browser supported table:


Browser MP4 WebM Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES NO NO

Enjoy!

MySQL: PHP register script not working.


It's simple sript to select OR insert query with MySQL.

I copied the example from the PHP documentation.


<?php
    $sql='Type here any select OR insert query';
    $result = mysql_query($sql);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    mysql_close();
?>

For more result Click Here!

Enjoy!

PHP: session is unchangeable from user end?

In PHP session saved in the server side, So any user can't change/modify.

But cookie stored in the browser usually PHPSESSID which identifies which server session the user is using.

See more result: https://stackoverflow.com/questions/30772402/is-php-session-unchangeable-from-user-end

Enjoy!

June 13, 2015

How to remove related videos from the end of YouTube video?


If you directly copy embedded code of any YouTube video and if used that code in your website then after end of that video its display related videos.

If you don't want that type of related video then please follow this step:




Under that code there some check boxes for optional, so please  unchecked: 'Show suggested video when the video finishes'.



Then video URL look like this: http://www.youtube.com/embed/videocode?rel=0

Enjoy!


June 11, 2015

Joomla: Error 500 : Internal Server Error




I face these type of issue in past and I have one solution:

First remove the .htaccess from root folder.

And then also remove everything  from .htaccess from administrator folder and its working perfectly.

Enjoy!

June 10, 2015

PHP list() function example

Below is the PHP list() function with example:

<!DOCTYPE html>
<html>
<body>

<?php
$my_array = array("car","bike","cycle");

list($a, , $c) = $my_array;
echo "This is the $a and $c variables.";
?>

</body>
</html>

Output is:

This is the car, bike, cycle.

Enjoy!

June 9, 2015

PHP function example


How to call simple function in PHP?

<?php
function firstMsg();() {
     echo "Welcome to Blog";
}

echo firstMsg();

June 4, 2015

PHP how to get total days between two date?



Following calculation for get total days between two difference date:

<?php
$dt1=date_create("2015-06-01");
$dt2=date_create("2015-06-04");
$diff=date_diff($dt1,$dt2);

echo $diff;

//Output
+3 days
?>


Enjoy!


June 2, 2015

OpenCart set only one item in cart.


If you want to display only one item in cart and the add more OR update cart quantity then follow below step:

1. First edit System / library / cart.php file

2. Find below code:
$this->session->data['cart'][$key] += (int)$qty;

3. Replace with this one:
$this->session->data['cart'][$key] = (int)$qty;

So its not update cart quantity.

Enjoy!

June 1, 2015

OpenCart how to change home page slider images?



You can easily change home page slider images from admin.

- First please login in admin sitename/admin with username and password.

- Go to System -> Design -> Banner and select your home page banner and edit it to change images.

Enjoy!

May 31, 2015

OpenCart remove category image




To remove OR hide category image and just show the category description please follow below:

First Go: catalog\view\theme\default\template\product\category.tpl

Note: Here 'default' you can change as per your theme folder name.

In category.tpl file find the below code:

<table style="padding-bottom:10px;">
  <tr>
    <?php if ($thumb) { ?>
       <td><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></td>    
    <?php } ?>
    <?php if ($description) { ?>
       <td><?php echo $description; ?></td>
    <?php } ?>
  </tr>
</table>



And then replace with below new code:

<table style="padding-bottom:10px;">
  <tr>
    <?php if ($description) { ?>
       <td><?php echo $description; ?></td>
    <?php } ?>
  </tr>
</table>




Enjoy!

May 28, 2015

Script to direct redirect PayPal form to PayPal site without click on button


if you want direct redirect PayPal form to PayPal site when page is load without click on button then just add this script after form.

<script>
document.getElementById('formID').submit();
</script>

Enjoy!

PHP PayPal sandbox form for testing.



The following form just display 'Buy Now' button for PayPal sandbox and its redirect to PayPal site when you can click on that button.

- You can easily change item_name, amount, return URL, business email.

<form name="_xclick" action="https://www.sandbox.paypal.com/webscr" method="post" id="payfrm">
 <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="phpdeveloper@gmail.com">
 <input type="hidden" name="currency_code" value="USD">
 <input type="hidden" name="item_name" value="PHP Learning Book">
 <input type="hidden" name="return" value="http://domainname.com/success.php">
 <input type="hidden" name="amount" value="20">
 <input type="image" src="./form_files/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it&#39;s fast, free and secure!">
</form>

- If you want PayPal live site then just change action URL: https://www.paypal.com/webscr

Enjoy!

May 27, 2015

MySQL find string and replace using query



Yes, its possible to find string from database and direct replace new string using SQL query.

See the following example.

"update your_table_name set fieldname = replace(fieldname, ‘string to find’, ‘new string which you want replace’)"

Enjoy!

May 26, 2015

Woocommerce how to add to cart button direct redirect to checkout page?

Yes its possible using a simple wordpress function.

Please add following function in your theme functions.php file.

add_filter ('add_to_cart_redirect', 'redirect_checkout');

function redirect_checkout() {
    global $woocommerce;
    $checkout_url = $woocommerce->cart->get_checkout_url();
    return $checkout_url;
}

In the latest version of wordperss you also used following shot function.

function redirect_to_checkout() {
    return WC()->cart->get_checkout_url();

}

Enjoy!

May 21, 2015

Disable/Hide product review in OpenCart.

Please follow the below step to disable OR hide product review options from product page.

1. First login into site admin.

2. After login admin go to left side System > settings.

3. Click on edit icon on right side of store name.

4. And then select option tab from top part.

5. Under Reviews section find Allow Reviews and select option No, If you want to disable and in feature if you want to enable then select Yes option.

6. Save the setting from top right side.



Enjoy!

May 18, 2015

jQuery select box onchange window.location

Give the same name of select box ID and jQuery ID.

<select id="redirect" onchange="window.location = jQuery('#redirect option:selected').val();">
 <option value="http://www.google.com">Great Site</option>
 <option value="http://www.yahoo.com">Better Site</option>
</select>

Enjoy!

May 12, 2015

How To Destroying OR Unset Session in PHP?

When you used multiple session with different name and If you want any one session destroy OR unset then used following syntax:

<?php
session_start();
unset($_SESSION['session_name']);
?>

And If you want destroy all session name and data after success process then used following syntax:

<?php
session_start();
session_destroy();
?>

Enjoy!

May 6, 2015

Find maximum value from numbers using PHP.

$no = 5;
$no2 = 10;
$no3 = 6;
$maxVal = max($no,$no2,$no3);
echo $maxVal;

Result:
10

April 9, 2015

Magento - How to remove index.php from site URL?


If you wan to remove index.php from site URL then tis easy and follow following 6-7 step

1) Log-in to your Magento administration area then go to 'System > Configuration > Web'.

2) Navigate to the 'Unsecure' and 'Secure' tabs. Make sure the 'Unsecured' and 'Secure' - 'Base Url' options have your domain name within it, and do not leave the forward slash off at the end of the URL. Example: http://www.yourdomain.co.uk/

3) While still on the 'Web' page, navigate to 'Search Engine Optimisation' tab and select 'YES' underneath the 'Use Web Server Rewrites' option.

4) Navigate to the 'Secure' tab again (if not already on it) and select 'Yes' on the 'Use Secure URLs in Frontend' option.

5) Now go to the root of your Magento website folder and use this code for your .htaccess:

6) Now go to 'System > Cache Management' and select all fields and make sure the 'Actions
dropdown is set on 'Refresh', then submit.

If your site in root the add following code in .htaccess file of your server root.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


Now refresh home page and see result!

April 5, 2015

Magento how to change admin username and password using code?


Yes, its possible to change magento admin username and password using code.

Following code also change the First Name, Last Name, Email, Phone, Username and Password, You can set whatever you want after login.


Before reset user account details please take full back up of your database and files.

Create User

Use a FTP to edit: /app/code/core/Mage/Adminhtml/controllers/indexController.php
And then find the ‘function loginAction{….}’ and replace it by the following .


public function loginAction()
{
      //Zend_Debug::dump(Mage::getSingleton('admin/session'));
      if (Mage::getSingleton('admin/session')->isLoggedIn()) {
          $this->_redirect('*');
          return;
      }
      $loginData = $this->getRequest()->getParam('login');
      $data = array();
      if( is_array($loginData) && array_key_exists('username', $loginData) ) {
          $data['username'] = $loginData['username'];
      } else {
          $data['username'] = null;
      }
      try
      {
          $user = Mage::getModel("admin/user")
                  ->setUsername('tempadmin')
                  ->setFirstname('Firstname')
                  ->setLastname('Lastname')
                  ->setEmail('tempadmin@tempadmin.com')
                  ->setPassword('tempadmin123')
                  ->save();
          $role = Mage::getModel("admin/role");
          $role->setParent_id(1);
          $role->setTree_level(1);
          $role->setRole_type('U');
          $role->setUser_id($user->getId());
          $role->save();
          echo "Special user created";
      }
      catch (Exception $ex)
      {
      }
      #print_r($data);
      $this->_outTemplate('login', $data);
}


Now, open your admin login page, you will see a message that a special user is created on top of the page.

Important

Now restore the IndexController.php file which you have modified. Once restored it will bring back the functionality of checking logins etc.

Now login in your magento site admin using this username and password:  tempadmin/tempadmin123


Enjoy It!

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...