Tuesday, 18 October 2011

Check user login with php


It is important to check whether the user is logged in for same security pages. like edit profile,friend etc.
If user is not logged in page is redirect to login page. Following code is useful for php websites.



function checked_login() {
 if(!isset($_SESSION['id'])) {
  ?>
   <script type="text/javascript" language="javascript">
    alert("<?php echo "Please Login ?>");
    window.location.href='<?php echo _BASEURL_; ?>/login.php';
   </script>
  <?
 //redirect2page('index.php');
 }
 }
define('_BASEURL_','http://localhost/hato1/'); //protocol required (http://)

How to call checked_login() function
<?php
session_start();ob_start();
checked_login();

PHP function for Auto select birth date month year


An user-defined function saves  us from  rewriting the same code again and again and helps us to make our application smaller. The given examples will help to understand how you can put them to work.
PHP has so many built-in functions, besides  that you can make your own functions as per the need. General structure of the user defined function is:
function function_name([mixed $var,.....]){ PHP code}
mixed is the datatype that means it could be of any datatype.
$var: is the name of the parameter, one function could have one,  more than one or no parameter.






1. PHP user define function to print birth Month , Date , Year .

Download Files


Html code
<tr height="20">
            <td align="right" class="normaltext">&nbsp;</td>
            <td align="right" class="normaltext"><div align="left">Date Of Birth:</div></td>
            <td align="left"><select name="month" id="month"  style="width:80px" class="whiteselectsmall">
                <?php print month_opt(get_month($uid)); ?>
              </select>
              <select name="day" id="day" style="width:40px" class="whiteselectsmall">
                <?php print set_day($uid);?>
              </select>
              <span class="normaltext">
              <select name="year" id="day" style="width:80px" class="whiteselectsmall">
              <?php print set_year($uid);?>
              </select>
              </span> </td>
          </tr>

PHP code
<?php 
 
//Database Information

$dbhost = "localhost";
$dbname = "pk";
$dbuser = "root";
$dbpass = "";

//Connect to database

mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$uid =1; // or you use session id   or  database table has ids 1,100,101 please change $uid value andrefresh page too see change....

?>  

<?php 
    
function get_month($user_id)
{
$query="select  bday from user where id='$user_id'";
 $res=mysql_query($query) or die(mysql_error());
 $row=mysql_fetch_array($res);
 $str=$row[0];
 $select=explode("-",$str);
 return $select[1];

}
    function month_opt($mon)
{
 $m=array(Month, Jan, Feb, Mar, April, May, Jun, July, August, Sep, Oct, Nov, Dec);
 for($i=1;$i<13;$i++)
 {
   if($i==$mon)
   $opt .= "<option value='$i' selected>$m[$i]</option>";   
   else
   $opt .= "<option value='$i'>$m[$i]</option>";
 }
 return $opt;
}


function set_day($user_id)
{
 $query="select  bday from user where id='$user_id'";
 $res=mysql_query($query) or die(mysql_error());
 $row=mysql_fetch_array($res);
 $str=$row[0];
 $select=explode("-",$str);
 
 for($i=1;$i<32;$i++)
 {
   if($i==$select[2])
   { 
     $opt .= "<option value='$i' selected>$i</option>";
   }
   else
   {
     $opt .= "<option value='$i'>$i</option>";
  //dsfl    
   }
 }
 return $opt;
}


function set_year($user_id)
{
// $user_id;
 $query="select  bday from user where id='$user_id'";
 $res=mysql_query($query) or die(mysql_error());
 $row=mysql_fetch_array($res);
 $str=$row[0];
 $select=explode("-",$str);

 $dat=date("Y");
 $start=$dat-80;
 for($i=$start;$i<$dat;$i++)
 {
   if($i==$select[0])
   { 
     $opt .= "<option value='$i' selected>$i</option>";
   }
   else
   {
     $opt .= "<option value='$i'>$i</option>";
  //dsfl    
   }
 }
 return $opt;
}
    ?>

Mysql code



-- Table structure for table `user`
-- 

CREATE TABLE `user` (
  `id` int(11) NOT NULL auto_increment,
  `uname` varchar(50) collate latin1_general_ci NOT NULL,
  `email` varchar(50) collate latin1_general_ci NOT NULL,
  `password` varchar(50) collate latin1_general_ci NOT NULL,
  `bday` date NOT NULL,
  `state` varchar(50) collate latin1_general_ci NOT NULL,
  `city` int(11) NOT NULL,
  `college` int(11) NOT NULL,
  `collstatus` int(11) NOT NULL,
  `collyear` int(11) NOT NULL,
  `time_zone` varchar(50) collate latin1_general_ci NOT NULL,
  `question` varchar(100) collate latin1_general_ci NOT NULL,
  `answar` varchar(50) collate latin1_general_ci NOT NULL,
  `blocked` enum('0','1') collate latin1_general_ci NOT NULL,
  `deactive` enum('0','1') collate latin1_general_ci NOT NULL default '0',
  `couse` text collate latin1_general_ci NOT NULL,
  `confirm` enum('0','1') collate latin1_general_ci NOT NULL default '0',
  `ccode` varchar(100) collate latin1_general_ci NOT NULL,
  `second_lastlogin` datetime NOT NULL,
  `lastlogin` datetime NOT NULL,
  `p_view` int(11) NOT NULL,
  `online` enum('0','1') collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=118 ;

-- 
-- Dumping data for table `user`
-- 

INSERT INTO `user` VALUES (1, 'user', 'user@user.com', 'user', '1982-08-22', '', 1, 1, 0, 0, '', '3', 'morning', '0', '0', 'sorry', '1', '', '2007-07-05 11:47:25', '2007-07-05 18:57:37', 19, '0');
INSERT INTO `user` VALUES (100, 'henery', 'henery@yahoomail.co.in', 'henery125', '1975-12-27', '5', 8, 0, 0, 0, '', '1', 'dog', '0', '0', '', '0', '5cdef582a2', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, '0');
INSERT INTO `user` VALUES (101, 'jax', 'jax@gamil.com', 'jax12345', '1982-07-25', '7', 19, 0, 0, 0, '', '4', 'joli', '0', '0', '', '0', '7e65a9b554', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, '0');






Getting Start With Joomla

Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications.Best of all, Joomla is an open source solution that is freely available to everyone.



What's a content management system (CMS)?

CMS or a 'Content Management System' quite literally allows you to control and manage the content within your web site - without technical training. Using this uncomplicated system you can very easily add, delete images and edit text in your web site on the fly. You can also have an unlimited number of pages and a full site-search engine. What's more... with 'Navega Bem - Web Design' you can have a highly professional CMS web site at a very reasonable price indeed!

If you are already familiar with 'Content Management Systems' then click here to see the advantages of our Joomla! or Drupal CMS solutions.




Download Source files of Joomla (Click Here)

Extract  the folder  into your server / local server .

Go to link localhost/folder name  (Root folder name where you extract the joomla source files).

Step 1 : Select language. 


Step 2 : Pre -Installation Checks. 


Step 4 : Joomla Licencee.


Step 4 : Database Configuration.



Step 5: Ftp Configuration.


Step 6: Main Configuration.



Step 7: Finish.


Go to root directory ad delete the folder name (installation).

\



First look of administrator account of website.


Please leave your valuable comments. 
Thank You 







Monday, 17 October 2011

7 free online stores templates

This time we want to show high quality free templates that can be used for creating online stores in any niche. Listed further online shop templates are developed by various design studios and companies using stock photos and will surely come in handy if you want to start you online business. The collection contains free css templates as well as free osCommerce templates. We hope that here you will find website template that will suit you perfectly. Also don’t forget to Like this page on facebook.


  Configure Files and start your online shopping website.


1.Free osCommerce Online Shop Template    Download 



2. Free osCommerce Pets Store Template     Download



3. Free osCommerce Online Store Template   Download

4. Free osCommerce Online Store Template   Download


5. Free osCommerce Flower Store Template   Download

6. Free osCommerce Digital Shop Template    Download






7. Free osCommerce Digital Shop Template    Download

I hope you enjoy this links .Please connect with us.

Sunday, 16 October 2011

Random Number And Alphabet Captcha Code With PHP

For Developing Random captcha code it is important to know Array , loop ,Array Rand and push function.

<? function randamString()
{
 $arr=array();
 for($i=65;$i<=91-1;$i++)
 { 
  array_push($arr,chr($i));
 }
 for($i=0;$i<=9;$i++)
 {
  array_push($arr,$i);
 } 
 $num=array_rand($arr, 6);
 $str.=$arr[$num[0]];
 $str.=$arr[$num[1]];
 $str.=$arr[$num[2]];
 $str.=$arr[$num[3]];
 $str.=$arr[$num[4]];
 $str.=$arr[$num[5]]; 
 return $str;
}
?>

Code Explanation 

 randamString() function is a user define function .
$arr is a variable that store array.
chr() — Return a specific character 
string chr ( int $ascii )
Returns a one-character string containing the character specified by ascii.

array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed. 

Array random function 
               array_rand — Pick one or more random entries out of an array.

$num=array_rand($arr, 6); function randomly select 6 value. $str. concatenate all the strings. now echo the function  <?php echo $str=randamString(); ?>




                                          
Download Folder