Menu bar

Saturday 28 June 2014

Redirection in wordpress with authorization and without authorization?

wp_redirect


The wp_redirect function is for redirecting all users to any absolute. URI. Absolute URIs are basically full URLs and look like this:

http://momin.com/book/http://momin.com/wp-contentredirecting-users.jpgftp://wordpress.com/transfer/

To redirect users with wp_redirect, place the following PHP snippet in your theme file with appropriate URL:

<?php
wp_redirect('http://example.com/'); exit; 
 ?>

The two parameters of wp_redirect are:
1> $location = The absolute URI to which the user will be redirected. No default.
2> $status = The status code to use. For example, 301, 302, etc. The default is 302.

<?php
// redirect to home page
wp_redirect(home_url()); exit; 
?>

<?php
// redirect back to current page
wp_redirect(get_permalink()); exit; 
?>

auth_redirect:

This extremely useful function checks whether or not the current user is logged in, and redirects them to the Login Page if not. By default, the user will be redirected back to the page from whence they came . Currently this function accepts no parameters.

<?php
 auth_redirect();
?>



Tuesday 24 June 2014

How to check whether java jdk is installed or not on windows?

After doing setup of  jdk, some user are in confusion whether the installation is completed successfully or not.
After jdk installation , user have to setup the PATH and JAVA_HOME variables.

here, jdk is the main folder.
PATH :  ..../jdk/bin          and                JAVA_HOME :  .../jdk

After completing all those step , open cmd prompt
Write java -version
if the output persist with java version means the jdk installed completely.
See the below images.



Monday 23 June 2014

Understanding Join Query.

Untitled Document Here we are goingto join two tables with common column named

Emp'Age' Table
EmpAge
Ron White32
Femina65
John25
Don

'Salary_Emp' Table
SalaryEmp
40000Ron White
29000Femina
25000
11000Ron White

The important thing to note here is that the column Emp contains information that can tie these two tables together. In the "Age" table, the Emp column contains all the Employee of the Company and their respective ages. In the "Salary_Emp" table the Emp column contains the respective Salary of the Employee. It's only through a shared column relationship such as this that tables can be joined together, so remember this when creating tables you wish to have interact with each other.
//php start
// Make a MySQL connection using your database credentials
// Construct our join query
$query = "SELECT Age.Emp, Salary_Emp.Salary ".
 "FROM Age, Salary_Emp".
 "WHERE Age.Emp = Salary_Emp.Emp";
  
$result = mysql_query($query) or die(mysql_error());


// Print out the contents of each row into a table 
while($row = mysql_fetch_array($result)){
 echo $row['Emp']. " - ". $row['Salary'];
 echo "
";
}
//php ends
EmpSalary
Ron White40000
Femina29000
Ron White11000

Saturday 21 June 2014

How to overcome Leverage Browser Caching?

What is LBC?

It is the way to remeber the resources that are loaded once on particular system.


Example:
It you visit http://www.mominiqbal.wordpress.com  say it as 'PAGE1', then you switch to new page say "PAGE2". Now from 'PAGE2'  if user switch to 'PAGE1' the resources will not be loaded again as it is already loaded earlier.


How to write LBC code?

To make Browser Caching Enable, we have to write the code in .htaccess file

<IfModule mod_expires.c>ExpiresActive On

#this will remeber the images for 1year.ExpiresByType image/jpg "access 1 year"ExpiresByType image/jpeg "access 1 year"ExpiresByType image/gif "access 1 year"ExpiresByType image/png "access 1 year"

#this will remeber the .css for 1 month.ExpiresByType text/css "access 1 month"

#this will remember the .html for 1 month.ExpiresByType text/html "access 1 month"

#this will remeber the .pdf for 1 month.ExpiresByType application/pdf "access 1 month"ExpiresByType text/x-javascript "access 1 month"

#this will remeber the flash file for 1 monthExpiresByType application/x-shockwave-flash "access 1 month"

#this will remeber the favicon for 1 monthExpiresByType image/x-icon "access 1 year"

#if access is not mention then default is this.ExpiresDefault "access 1 month"</IfModule>

Monday 16 June 2014

How to style table using CSS?

No explanation needed for you buddy :)
This is as simple as you see here..


Table 1

Html code for Table 1

<table id="gradient-style" summary="Meeting Results">
<thead>
<tr>
<th scope="col">Employee</th>
<th scope="col">Division</th>
<th scope="col">Suggestions</th>
<th scope="col">Rating</th></tr>
</thead>

<tfoot>

<tr><td colspan="4">Give background color to the table cells to achieve seamless transition</td></tr>
</tfoot>

<tbody>

<tr><td>Stephen C. Cox</td><td>Marketing</td><td>Make discount offers</td><td>3/10</td></tr>
<tr><td>Josephin Tan</td><td>Advertising</td><td>Give bonuses</td><td>5/10</td></tr>
<tr><td>Joyce Ming</td><td>Marketing</td><td>New designs</td><td>8/10</td></tr>
<tr><td>James A. Pentel</td><td>Marketing</td><td>Better Packaging</td><td>8/10</td></tr>
</tbody>
</table>


CSS code for Table 1

<style>
#gradient-style{
font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size:12px;
width:480px;
text-align:left;
border-collapse:collapse;
margin:20px;
}
#gradient-style th{
font-size:13px;font-weight:normal;
background:#9C9 url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/gradhead.png") repeat-x;
border-top:2px solid #d3ddff;
border-bottom:1px solid #fff;
color:#039;padding:8px;
}
#gradient-style td{
border-bottom:1px solid #fff;
color:#669;
border-top:1px solid #fff;
background:#9c9 url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/gradback.png") repeat-x;
padding:8px;
}
#gradient-style tfoot tr td{
background:#e8edff;
font-size:12px;
color:#99c;
}
#gradient-style tbody tr:hover td{
background:#9c9 url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/gradhover.png") repeat-x;
color:#339;
}
</style>


Table 2

Html code for Table 2


<table id="pattern-style-a" summary="Meeting Results">
<thead>
<tr>
<th scope="col">Employee</th>
<th scope="col">Salary</th>
<th scope="col">Bonus</th>
<th scope="col">Supervisor</th></tr>
</thead>
<tbody>
<tr><td>Stephen C. Cox</td><td>$300</td><td>$50</td><td>Bob</td></tr>
<tr><td>Josephin Tan</td><td>$150</td><td>-</td><td>Annie</td></tr>
<tr><td>Joyce Ming</td><td>$200</td><td>$35</td><td>Andy</td></tr>
<tr><td>James A. Pentel</td><td>$175</td><td>$25</td><td>Annie</td></tr>
</tbody>
</table>


CSS code for Table 2

<style>
#pattern-style-a{
font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size:12px;
width:480px;
text-align:left;
border-collapse:collapse;
background:url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/pattern.png");
margin:20px;
}
#pattern-style-a thead tr{
background:url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/pattern-head.png");
}
#pattern-style-a th{
font-size:13px;
font-weight:normal;
border-bottom:1px solid #fff;
color:#039;
padding:8px;
}
#pattern-style-a td{
border-bottom:1px solid #fff;
color:#669;
border-top:1px solid transparent;
padding:8px;
}
#pattern-style-a tbody tr:hover td{
color:#339;
background:#fff;

}
</style>

Table 3

Html code for Table 3

<table id="pattern-style-b" summary="Meeting Results">
<thead>
<tr>
<th scope="col">Nation</th>
<th scope="col">Capital</th>
<th scope="col">Language</th>
<th scope="col">Unique</th>
</tr>
</thead>
<tbody>
<tr><td>Japan</td><td>Tokyo</td><td>Japanese</td><td>Karate</td></tr>
<tr><td>South Korea</td><td>Seoul</td><td>Korean</td><td>Ginseng</td></tr>
<tr><td>China</td><td>Beijing</td><td>Mandarin</td><td>Kung-Fu</td></tr>
<tr><td>Indonesia</td><td>Jakarta</td><td>Indonesian</td><td>Batik</td></tr>
</tbody>
</table>


CSS code for Table 3

<style>
#pattern-style-b{
font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size:12px;
width:480px;
text-align:left;
border-collapse:collapse;
background:url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/patternb.png");
margin:20px;
}
#pattern-style-b thead tr{
background:url("http://www.smashingmagazine.com/images/express-css-table-design/table-images/patternb-head.png");
}
#pattern-style-b th{
font-size:13px;
font-weight:normal;
border-bottom:1px solid #fff;
color:#039;
padding:8px;
}
#pattern-style-b td{
border-bottom:1px solid #fff;
color:#669;
border-top:1px solid transparent;
padding:8px;
}
#pattern-style-b tbody tr:hover td{
color:#339;
background:#cdcdee;
}
</style>

Sunday 1 June 2014

How to optimize page speed of your wordpress website quickly?

To make your wordpress website load better then ever, you need to download the plugin named W3 Total Cache , install and activate it....
Now goto Google developer tool to check your pagespeed result on Desktop as well as on Mobile Platform.This is to check that after installing plugin and doing following setting  as shown in the following images , you will get the better result then ever.
After installing the plugin , see below 5 images and do setting  accordingly in your plugin menu tab.

Step : 1 General Setting Tab



Step :2 Page Cache Tab





Step: 3 Minify Tab





Step:4 Database Cache Tab




Step : 5 Browser Cache Tab






Remain all other tab as it is in your plugin setting and check the google page speed again you will definitely have a smile on your face :)