Friday, 12 July 2013

ebook Link for free

http://it-ebooks.info/search/?q=cakephp&type=title

http://freecomputerbooks.com/search.html?cx=partner-pub-5976068913745703%3Ae0ybf3af0rc&cof=FORID%3A10&ie=ISO-8859-1&q=O%27Reilly&sa=Go

http://it-ebooks.info/search/?q=adobe+photoshop+cs6+&type=title

Wednesday, 19 June 2013

jquery-ajax

http://www.jquery4u.com/function-demos/ajax/

http://www.ajax-zoom.com/examples/example26.php

http://api.jquery.com/live/


w3schools.in

Saturday, 8 June 2013

Check Box in php

http://www.html-form-guide.com/php-form/php-form-checkbox.html

http://www.phpeasystep.com/mysql/8.html

http://www.homeandlearn.co.uk/php/php4p11.html

http://www.c-sharpcorner.com/UploadFile/051e29/insert-value-from-radio-button-in-mysql-in-php/

http://www.phpforkids.com/php/php-forms-get-post-checkbox-radio-data.php

http://www.homeandlearn.co.uk/php/php4p10.html

Wednesday, 5 June 2013

Bootstrap Zend Tute

http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch-models-and-integrating-doctrine-orm/

http://roysimkes.net/blog/2009/07/setting-up-a-zend-framework-project-from-scratch/

http://randomitstuff.com/2010/05/04/setting-up-database-configuration-in-zend-framework/


Reading csv file xls file

http://php-drops.blogspot.in/2011/04/read-excel-sheet-xls-file-with-php.html

http://www.homeandlearn.co.uk/php/php10p6.html

Simple Email in PHP

simpleEmail.php

<?php
/* include_once 'library/EmailMarketing.php';
include_once 'application/simple-email/index.php'; */
session_start();
include ('include/header.php');


/* $obj= new SimpleEmail();
$obj->abc(); */
?>
<div style="width:1000px;margin:auto;padding:10px;">
<h2>Send Mail From Here</h2>
<h3 style="color:green">
<?php
if(isset($_SESSION['msg'])) echo $_SESSION['msg'];

?></h3>
<form method="post" action="library/simpleMail.php">
<table>
<tr><td>To</td><td><input type="text" name="to"></td></tr>
<tr><td>From</td><td><input type="text" name="from"></td></tr>
<tr><td>Subject</td><td><input type="text" name="subject"></td></tr>
<tr><td valign="top">Message</td><td><textarea rows="10" cols="50" name="message"></textarea></td></tr>
<tr><td><input type="submit" name="send" value="Send">
</table>
</form>
</div>
<?php
include 'include/footer.php';

sleep(3);
unset($_SESSION['msg']);





libray/simpleEmail.php




<?php
session_start();
//echo "Hello";exit;
if($_POST['send'])

{

$to = $_POST['to'];

$from = $_POST['from'];

$subject = $_POST['subject'];

$msg = $_POST['message'];   

//$mail = "aayijaaij@gmail.com";
//$to="mantu.kumar@samparkweb.com";
//$subject="Registration Confirmation";



    $data= "<table>   
    <tr><td>$msg</td></tr>
    </table>";

    $headers = "MIME-Version: 1.0" . "\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1 ". "\r\n";

    $headers .= "Suject:$subject" . "\r\n";
   
    $headers .= "From:$from" . "\r\n";

    $data=mail($to,$subject,$data,$headers);

 if(isset($data))

 {
     //echo "Data Send Sucessfully";
     $_SESSION['msg']="Mail Sended Successfully !";
     //header('Location:http://www.diversifiedseo.com/email-marketing/application/simple-email/test.php');
     header('Location:http://www.diversifiedseo.com/email-marketing/simpleEmail.php');
 }
}
else
{
   
    header('Location:delhibid.com');
}

?>

Tuesday, 4 June 2013

what is the use of @ in PHP?

The @ symbol is the error control operator (aka the "silence" or "shut-up" operator). It makes PHP suppress any error messages (notice, warning, fatal, etc) generated by the associated expression. It works just like a unary operator, for example, it has a precedence and associativity. Below are some examples:
@echo 1 / 0;
// generates "Parse error: syntax error, unexpected T_ECHO" since 
// echo is not an expression

echo @(1 / 0);
// suppressed "Warning: Division by zero"

@$i / 0;
// suppressed "Notice: Undefined variable: i"
// displayed "Warning: Division by zero"

@($i / 0);
// suppressed "Notice: Undefined variable: i"
// suppressed "Warning: Division by zero"

$c = @$_POST["a"] + @$_POST["b"];
// suppressed "Notice: Undefined index: a"
// suppressed "Notice: Undefined index: b"

$c = @foobar();
echo "Script was not terminated";
// suppressed "Fatal error: Call to undefined function foobar()"
// however, PHP did not "ignore" the error and terminated the
// script because the error was "fatal"
What exactly happens if you use a custom error handler instead of the standard PHP error handler:
If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) call error_reporting() which will return 0 when the call that triggered the error was preceded by an @.
This is illustrated in the following code example:
function bad_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
    echo "[bad_error_handler]: $errstr";
    return true;
}
set_error_handler("bad_error_handler");
echo @(1 / 0);
// prints "[bad_error_handler]: Division by zero"
The error handler did not check if @ symbol was in effect. The manual suggests the following:
function better_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
    if(error_reporting() !== 0) {
        echo "[better_error_handler]: $errstr";
    }
    // take appropriate action
    return true;
}

Saturday, 1 June 2013

Magento Currency Chage from Home page

http://webdesignsolutions.co.in/how-to-add-currency-selector-to-magentos-header

Friday, 17 May 2013

htaccess

http://www.isitebuild.com/301-redirect.htm

http://www.phptechi.com/how-to-create-a-featured-product-module-in-magento.html

Thursday, 18 April 2013

Imp Link for Magento & Zend


http://www.lotusseedsdesign.com/blog/magento-static-callout-block

http://hkpatel201.blogspot.in/2013/02/simple-image-slider-magento.html

http://www.stoimen.com/blog/2009/06/19/zend-framework-quick-tutorial-part-3-front-controller-plugins/

http://www.blog.magepsycho.com/category/magento/

http://samsonasik.wordpress.com/2012/09/27/zend-framework-2-using-zendcache-and-hydratingresultset-to-save-database-resultset/

http://www.tutorial-portal.com/tutorial/48/set-default-controller-action-and-module

http://www.pierrefay.com/magento-developper-guide-howto-tutorial-5

http://codeutopia.net/blog/articles/

http://www.amazium.com/blog/content-driven-access-control-with-zend-acl

http://blog.ricky-stevens.com/zend-framework-doctrine-apc/

Monday, 15 April 2013

Html Entities and Html special chars

You want to convert the HTML character into their corresponding HTML entities.
FOr that you can Use Functions 
  1. htmlentities ()
  2. htmlspecialchars()
For example ===
Form Having Text area
<form action="" method="POST">
<textarea name="address"></textarea>
<input type="submit" >


PHP part

<?php
$a htmlentities($_POST['address']);
echo $a;

//or 
$b = htmlspecialchars($_POST['address']);
echo $b;

//If you want to convert those entities back into HTML character

echo html_entity_decode($a);

echo "</br>";

echo html_entity_decode($b);


Now if you ask which one will be best then ..

htmlentities() can translate anything as listed in Manual

while htmlspecialchars() translate only specialcharacter

For DEtails Refer These Links

Sunday, 14 April 2013

How to install zend framework - 2

Follow the instructions of below given link

http://samminds.com/2012/07/zend-framework-2-installation-on-xampp-for-windows/

Saturday, 6 April 2013

best zend reference link

http://files.zend.com/help/Zend-Framework/index.html

http://perevodik.net/en/posts/10/

http://zendcoding.com/

http://forums.eukhost.com/f15/install-zend-framework-under-linux-cpanel-shared-account-10753/#.UWzeWEpj8Tg

Thursday, 4 April 2013

how to generate random number between given two number

$max = 1.0;
    $min = 0.0;
    for($i=0;$i<100;$i++)
    {
        print ("<br>");
        $range = $max-$min;
        $num = $min + $range * mt_rand(0, 32767)/32767;    
        $num = round($num, 2);    
        print ((float) $num);
    }

Wednesday, 3 April 2013

Link of PHP Help

http://www.plus2net.com/

http://www.phpeasystep.com/index.php

Saturday, 30 March 2013

Thursday, 21 March 2013

Essential Link

http://mahtonu.wordpress.com/tag/ajax/

http://prototypejs.org/doc/latest/ajax/Ajax/Request/

For Zend - http://mahtonu.wordpress.com/category/php/zend-framewrk/

Zend Video - http://www.zendcasts.com/ajaxify-your-zend_form-validation-with-jquery/2010/04/

viewHelper - http://stackoverflow.com/questions/1616857/best-way-to-start-using-jquery-in-a-zend-framework-1-9-application

zend slide - http://www.slideshare.net/dennisdc/introduction-to-zendx-jquery-3531425

zend Nice Tute - http://zendgeek.blogspot.in/2009/07/zend-framework-and-jquery-jquery-date.html



Best For Admin Panel - http://blog.luisfreitas.pt/2010/11/06/how-to-build-a-complete-zend-framework-application/

http://www.phpriot.com/articles/fetch-data-with-zend-db

http://devzone.zend.com/1240/decorators-with-zend_form/
http://zendgeek.blogspot.in/2009/07/zend-framework-and-jquery-jquery-date.html
http://stuntcoders.com/tag/zend-framework/


http://freemp3x.com/english-guru-spoken-english-course-mp3-download.html

http://www.programming-free.com/2013/02/image-zoom-plus-fancybox-feature-using.html#.UYeLVkpj8Tg

http://www.javascriptsource.com/miscellaneous/popup-div.html#

Wednesday, 20 March 2013

Paginating Records in Zend

Source : http://e-university.wisdomjobs.com/zend/

Applications can contain hundreds and even millions of records. Members of a site, artist information, a list of images.all these items can be displayed. If the application contained hundreds of records and displayed the content to the user all at once, the user would be overwhelmed with too much data at a single time. The user also might become frustrated by the time it takes for the content to load because the query would fetch all the records at once.

You can solve the dilemma by using pagination, which allows applications to fetch smaller result sets there by displaying content in manageable and faster loading portions. The result sets are usually broken up into numbered pages. For example, if you have 1,000 records and applied pagination, you can display the content in a set 10 pages, each page containing 100 records. As the user continues to click on the next page, the application retrieves the next set of data. 

To add pagination to any application, you can use the Zend_Paginator library, which has the capability to paginate any collection of data in an array as well as result sets from a database using the Zend_Db_Select object. It also allows you to apply any type of view to render the content.

Using the Zend_Paginator

The Zend_Paginator can be used by loading the Zend_Paginator class into a PHP file.
After the class is loaded, you can instantiate a Zend_Paginator object using its constructor and supply it with a Zend_Paginator_Adaptor object. The supported adaptors are the following:
  • Zend_Paginator_Adaptor_Array
  • Zend_Db_Select
  • Zend_Db_Table_Select
  • . Iterator
Depending on the type of data you want to paginate, use the required adaptor. If you want to paginate data for an array, use the Zend_Paginator_Adaptor_Array class. To use database result sets, you can create either a Zend_Db_Select object or a Zend_Db_Table_Select object. You can also allow Zend_Paginator to automatically create the adaptor for you by using the Zend_ Paginator :: factory() method and pass in an array or the object you want to use.

The Zend_Paginator provides additional functionality to manipulate the data presented to the user. These methods are shown in Table.



Aside from providing helpful methods, Zend_Paginator requires interaction by the user. The user must click a given page number to inform the Zend_Paginator what set of records it needs to fetch. Depending on the current page the user is on, a different set of records will be displayed. To determine which page the user is requesting, you need to use a query to pass in the data. Retrieving the page number is then something the PHP file must capture using the Request object.

Using the table, lets work on a small example that will use the methods and the factory() method. What youll need is an action and a view. Open the ArtistController.php file and create listAction(). The action will contain the pagination example shown in Listing.

Listing ArtistController.php: listAction()
/**
  * Display all the Artists in the  system.
  */

  public function listAction(){

  //Create a sample array of artist
  $artist = array("Underworld", "Groove Armada",  "Daft Punk",
  "Paul Oakenfold", "MC Chris",     
  "Ramones",
  "The Beatles", "The Mamas and the Papas",
  "Jimi Hendrix");

//Initialize the Zend_Paginator
  $paginator =  Zend_Paginator::factory($artist);
  $currentPage = 1;
//Check if the user is not on page 1
  $i =  $this->_request->getQuery('i');
  if(!empty($i)){ //Where i is the current page
  $currentPage = $this->_request->getQuery('i');
  }

//Set the properties for the pagination
  $paginator->setItemCountPerPage(2);
  $paginator->setPageRange(3);
  $paginator->setCurrentPageNumber($currentPage);
  $this->view->paginator =  $paginator;
}
 
Listing demonstrates the new listAction(). The method begins by initializing the data youll paginate through. Its a set of nine electronic music artists, all contained in an $artist array. Once initialized, you create a Zend_Paginator object and use its factory method to pass in the data to paginate. Because youre using an array, this will become a Zend _Paginator _Adaptor _Array object behind the scenes.

You now need to determine what page the user is on. To do this, pass a query value using the URL. The query value is represented by the variable i, and the URL will look like this:. If the variable i is not set, you know that the user is in the initial page, and you can use the default value you set as 1. Finally, set the total number of artists to display in a single page, 2; set the number of pages to display in the paginator control, 3; and set the page the user is currently loading for this request.

Create a new file in the views/scripts/artist directory and call it list.phtml. The view will render the records. Copy the code shown in Listing into the list.phtml file.
 
Listing list.phtml
<?php echo $this->doctype('XHTML1_STRICT'); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
<?php echo $this->headTitle('LoudBite.com - Artist Listing'); ?>
 </head>
 <body>
<?php echo $this->render("includes/header.phtml")?>
<table border='0' width='600'>
<?php
          if ($this->paginator)
          {
               foreach($this->paginator as $item)
              {
                    echo "<tr><td>".$item."</td></tr>";
              }
         }
        else{?> <tr>
<td>There were no artists present in the system. Add one now!</td></tr> <?php } ?> </table> </body>
 </html>

Listing builds on the example shown in Listing. Unlike the previous example, you append the call to render the paginator’s control. You use the paginationControl() method to do so and pass in three parameters. The initial parameter is the object you created in the listAction: $paginator. The second parameter is the scrolling style from Table. The third parameter is the location of the pagination control view; in the example, it’s in the includes folder. the resulting pagination controller and the list of artists, as shown below.



 
 




Monday, 18 March 2013

How to Install Zend Framework



Create 3 directory in your project directory i.e.  application, library and public

after that follow the following steps -

1. download the latest library file for zend and paste the library's zend folder in library section.
2. create the following folder in the application folder -
                configs, controllers, models, views, forms, layouts

3. create a index.php in the public folder and paste the following code
 --------------------------------Start Index.php ------------------------------------------------------------
<?php
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();


------------------------------------------- End of Index.php---------------------------------------------


4. create a .htaccess file in the public folder

------------------  .htaccess --------------------------

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

---------------------- End of file ---------------------------------------


5.       create a Bootstrap.php file in the application folder

--------------  Bootstrap.php -----------------

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{


}

------------------- End of file ----------------


6. create a application.ini file in the configs folder

-----------------------  application.ini -------------------

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/London"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = root
resources.db.params.dbname = zf-tutorial
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

resources.db.params.profiler.enabled    = true
resources.db.params.profiler.class      = Zend_Db_Profiler_Firebug

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
phpSettings.error_reporting = -9



free css-template

For finding awesome free css template visit the following link

http://www.free-css.com/free-css-templates/page1

Tuesday, 12 March 2013

The Difference Between DNS and Name Servers



The DNS (Domain Name System) is a massive network of servers that comprises the largest digital database on the planet. This database is maintained, managed and regulated by several internet authorities, including the IANA (Internet Assigned Numbers Authority) and ICANN (Internet Corporation for Assigned Names and Numbers). 
Many people confuse the various terms associated with the DNS and mistakenly refer to them as either the same thing or completely separate entities. In truth, they are neither separate nor are they the same thing; rather, they are integral pieces to the puzzle that is the world wide web.
If you're interested in learning the difference between a DNS and a name server, then you may want to consider the following information.
What is the DNS?
Contrary to a seemingly popular misconception, DNS does not stand for Domain Name Server or Domain Name Software. DNS is an abbreviation for the aforementioned system that catalogs every domain and IP address on the internet, including registration information, as well as their relation to other domains and web hosts. The DNS is the central database of the internet, and without it, the internet would cease to exist as we know it.
Before the domain name system was devised, computers would connect to each other via IP addresses, which are strings of segmented numbers separated by dots. An example of an IP address would be 127.0.0.1 (a common IP address for a local router). The domain name system attaches a name to this number so that site visitors can easily remember and return to web addresses.
What is DNS Software?
DNS software is a program that is installed on a web server and used to facilitate the transference of data related to the domain name system. Technically, any web server can have DNS software installed on it, making the server a name server; however, some web hosts will not allow you to install or configure software within your hosting control panel, especially in shared hosting plans.
If you’re interested in installing DNS software on a web server to create a custom nameserver, you'll either need a VPS or dedicated hosting plan, unless you'd like to invest several thousand dollars in a private web server.
What is a Name Server?
A name server is a web server that has DNS software installed on it, particularly a server that is managed by a web host that is specifically designated for managing the domain names that are associated with all of the hosting provider's accounts.
Name servers are often called DSN servers as well, and this is likely the origin of all of the confusion associated with name servers and the DNS.
Every web site has two name servers to which it is pointed, and this process must be done by the webmaster upon purchasing a domain and a hosting account. If you have more questions about domain name pointing and your web hosting name servers, it is recommended that you contact your web hosting provider.

Thursday, 7 March 2013

PHP manual installation

Following link is useful for manual installation of PHP in Windows

http://www.premiumwebbloghosting.com/2012/03/how-to-install-php-on-windows-7.html

Apache Manual installation


Follow the following link to install apache manually

http://www.premiumwebbloghosting.com/2013/02/manually-installing-apache-server-on-windows-7.html

making-a-oscommerce-template-all-the-progress-step-by-step


Follow the folling link -

http://multimixer.gr/16/05/2011/making-a-oscommerce-template-all-the-progress-step-by-step/

Tuesday, 26 February 2013

Perfect Javascript Form Validation using Regular Expressions.

I had designed a perfect form validation using javascript regular expression. Simple code and works perfect in all conditions. It's very useful and supporting all the web browsers just take a look at post live demo.




Name:
Alphabets, numbers and space(' ') no special characters min 3 and max 20 characters.


var ck_name = /^[A-Za-z0-9 ]{3,20}$/;

Learning JavaScript, 2nd Edition

Email
Standard email address
var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

UserId
Supports alphabets and numbers no special characters except underscore('_') min 3 and max 20 characters.
var ck_username = /^[A-Za-z0-9_]{3,20}$/;

Password
Password supports special characters and here min length 6 max 20 charters.
var ck_password = /^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;


JavaScript Code:
You have to include this code within the tag HEAD of the page.
<script type="text/javascript">
var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]
{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
var ck_username = /^[A-Za-z0-9_]{1,20}$/;
var ck_password =  /^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;

function validate(form){
var name = form.name.value;
var email = form.email.value;
var username = form.username.value;
var password = form.password.value;
var gender = form.gender.value;
var errors = [];
 
 if (!ck_name.test(name)) {
  errors[errors.length] = "You valid Name .";
 }
 if (!ck_email.test(email)) {
  errors[errors.length] = "You must enter a valid email 
address.";
 }
 if (!ck_username.test(username)) {
  errors[errors.length] = "You valid UserName no special 
char .";
 }
 if (!ck_password.test(password)) {
  errors[errors.length] = "You must enter a valid Password ";
 }
 if (gender==0) {
  errors[errors.length] = "Select Gender";
 }
 if (errors.length > 0) {

  reportErrors(errors);
  return false;
 }
  return true;
}
function reportErrors(errors){
 var msg = "Please Enter Valide Data...\n";
 for (var i = 0; i<errors.length; i++) {
 var numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
}
 alert(msg);
}
</script>

HTML Code
You have to modify action="#"
<form method="post" action="#" onSubmit="return validate(this);" name="form">

</form>

Htaccess File Inside The Folder.

How to use .htaccess file inside the folder. I'm using two .htaccess files in my hosting, one for labs.9lessons and another for touch.9lessons. Just take a look at this post how I had implemented.










Original URL : http://www.9lessons.info/touch/index.php?id=srinivas
to
Friendly URL : http://touch.9lessons.info/srinivas

First .htaccess file
This code redirects sub domain http://touch.9lessons.info pointing to touch folder.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^touch\.9lessons\.info$
RewriteCond %{REQUEST_URI} !^/touch/
RewriteRule (.*) /touch/$1

Second .htaccess file
This file inside the touch directory. Contains single parameter URL rewriting code.
RewriteEngine On

RewriteBase /touch/

RewriteEngine On

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1

Old Posts about .htaccess
  1. Redirect The Sub Domain To a Sub Folder with .htaccess
  2. URL Rewriting Tip with .htaccess File
  3. Pretty URLs with .htaccess Rewriting Tips.
  4. Add Security to your PHP projects using .htaccess file

SEO Friendly URLs with PHP

This post explains how to create SEO friendly URL with dynamic content using PHP and .htaccess mod redirection. Friendly URLs improves your site search engines ranking. Before trying this you have to enable mod_rewrite.so module at httpd.conf. It’s simple just few lines of PHP code converting title data to clean URL format.

Database
Sample database blog table columns id, title, body and url.

CREATE TABLE blog
(
id INT PRIMARY KEY AUTO_INCREMENT,
title TEXT UNIQUE,
body TEXT,
url TEXT UNIQUE,
);
Publish.php
Contains PHP code. Converting title text to friendly url formate and storing into blog table.
<?php
include('db.php');
function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string);
return implode(' ', array_slice($words, 0, $word_limit));
}

if($_SERVER["REQUEST_METHOD"] == "POST")
{
$title=mysql_real_escape_string($_POST['title']);
$body=mysql_real_escape_string($_POST['body']);
$title=htmlentities($title);
$body=htmlentities($body);
$date=date("Y/m/d");
//Title to friendly URL conversion
$newtitle=string_limit_words($title, 6); // First 6 words
$urltitle=preg_replace('/[^a-z0-9]/i',' ', $newtitle);
$newurltitle=str_replace(" ","-",$newtitle);
$url=$date.'/'.$newurltitle.'.html'; // Final URL
//Inserting values into my_blog table
mysql_query("insert into blog(title,body,url) values('$title','$body','$url')");
}
?>
//HTML Part
<form method="post" action="">
Title:
<input type="text" name="title"/>
Body:
<textarea name="body"></textarea>
<input type="submit" value=" Publish "/>
</form>

Article.php
Contains HTML and PHP code. Displaying content from blog table.
<?php
include('db.php');
if($_GET['url'])
{
$url=mysql_real_escape_string($_GET['url']);
$url=$url.'.html'; //Friendly URL 
$sql=mysql_query("select title,body from blog where url='$url'");
$count=mysql_num_rows($sql);
$row=mysql_fetch_array($sql);
$title=$row['title'];
$body=$row['body'];
}
else
{
echo '404 Page.';
}
?>
//HTML Part
<body>
<?php
if($count)
{
echo "<h1>$title</h1><div class='body'>$body</div>";
}
else
{
echo "<h1>404 Page.</h1>";
}
?>
</body>

.htaccess
URL rewriting file. Redirecting original URL 9lessons.info/article.php?url=test.html to 9lessons.info/test.html
RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+).html$ article.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ article.php?url=$1