Thursday, December 13, 2012

Auto Fill second input box js

Auto Fill second input box Java Scripts 




when you fill first  input box above second one fills automatically by using the Java Scripts bellow

<html>
<head>
<script type="text/javascript">
    function copy_data(val){
     var a = document.getElementById(val.id).value
     document.getElementById("copy_to").value=a
    }

    </script>
</head>
<body>
<input type="text" name ="a" id="copy_from" onkeyup="copy_data(this)"/>
<input type="text" name ="a" id="copy_to"/>
</body>
</html>

Thursday, December 6, 2012

Elapse time, cookies name and last visited, page load time Java Scripts



Elapse time, cookies name and last visited, page load time Java Scripts 


Following piece of java Scripts code will show you cookie name and the date of last visited the site.

<!DOCTYPE html>
<html>
<head>
<script>
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
var username=getCookie("username");
if (username!=null && username!="")
  {
  alert("Welcome again " + username);
  }
else
  {
  username=prompt("Please enter your name:","");
  if (username!=null && username!="")
    {
    setCookie("username",username,365);
    }
  }
}
</script>
<script type = "text/javascript">



var days = 730;
var lastvisit=new Object();
var firstvisitmsg="This is your first visit to this page. Welcome!";
lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>";

lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}

lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();

var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}

else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat");
var month = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm
document.write(lastvisit.subsequentvisitmsg.replace("\[displaydate\]", dispDate))
}

lastvisit.setCookie("visitc", wh, days);

}

lastvisit.showmessage();

</script>
</head>
<body onload="checkCookie()">
</body>
</html>

Bellow codes of Java Scripts shows you elapse time stayed in a specific page as countdown timer 

<html>
<head>
<title>load</title>

<Script Language="JavaScript">

var startDate = new Date();
var startTime = startDate.getTime();

function seconds_elapsed ()
{
var date_now = new Date ();
var time_now = date_now.getTime ();
var time_diff = time_now - startTime;
var seconds_elapsed = Math.floor ( time_diff / 1000 );

return ( seconds_elapsed );
}

function time_spent ()
{

var secs = seconds_elapsed ();


var mins = Math.floor ( secs / 60 );
secs -= mins * 60;


var hour = Math.floor ( mins / 60 );
mins -= hour * 60;


document.display.timeElapsed.value = pad ( hour ) + ":" + pad ( mins ) + ":" + pad ( secs );


setTimeout( "time_spent ()", 1000 );
}

function pad ( num )
{
return ( ( num > 9 ) ? num : "0" + num );
}
</Script>
</head>

<body onLoad="time_spent()">

<form name="display">
<input name="timeElapsed" type="text" size=8>
</form>

</body>
</html>

Following codes are really php in which you can find the tame taken to page load. 

<html>
<head>
</head>
<body>
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>
<body>
<html>

Tuesday, December 4, 2012

HTML Save as word doc

HTML Save as word doc

HTML body content could be save as Microsoft word document by using PHP file as bellow including header information to save as word document.

<?php
  
header("Content-type: application/vnd.ms-word");
  
header("Content-Disposition: attachment; Filename=SaveAsWordDoc.doc");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\">
<title>Saving HTML as a Word Doc</title>
</head>

<body>
<table border=1 align="center">
<tr><td>Name</td><td>Age</td></tr>
<tr><td>Mark Taylor</td><td>34</td></tr>
<tr><td>Oksana dassie</td><td>32</td></tr>
<tr><td>Oksana Babiac</td><td>38</td></tr>
<tr><td>karina kpoor</td><td>22</td></tr>
<tr><td>Alisa diction jonson</td><td>48</td></tr>
</table>
</body>
</html>

Friday, November 30, 2012

E-Money With Advertising

E-Money With Advertising 


This is a simple way of earning money from your site and also effective method.Here the advertisers come to your site automatically by implementing HTML codes of advertisers in your site.Then automatically advertisements will be displayed in your site.
                      If you have a site with good content and good traffic,You could be happy with continuous income   flowing to you .By this you can earn always even with away from your computer and even in sleeping.
I have listed bellow a few of best web advertisers.


Google Ad sense

Infolinks

BuySellAds

Chitika

Adbrite

Kontera

Bidvertiser

Clicksor



Thursday, November 29, 2012

E-Money With Web Affiliate

E-Money With Web Affiliate 


Affiliate marketing is a best way of earning money through internet.By introducing good and services through your web/blog site or through E-mail.you could earn  money according to your skills.Selecting goods or service which need to lot of people is very important.
                           First  you have to register the site where affiliate is provided.Then you will get rifer link or banner through which you can register the person interested with particular good or service.If the person registered to buy a good or service you will get 10%-25% commission from the sale.
                                It is very important to select good or service which  are good in market than same kind and low in  price.
Following are the best affiliate program links






  
 

Wednesday, November 28, 2012

e.money with adf.ly

e.money with adf.ly 



adf.ly is a site,which shares links and allow us to earn money.We could get $4 for 1000 visitors maximum.We can short the link from this site and release these shorten links to the cyber space. Shortened links are directed to advertisements and then redirected to original links allowing us to earn money from these adds.
start with registering free in  http://adf.ly


log in to your account and use shrink to shortened URL


Payments are high in amount with the click in United States,United Kingdom,Canada,Australia like countries.Payment for other countries you could find from
 The ways of getting visitors


01. Leave comments in blogs

02. Answer questions in genre related forums and blogs

03. Get yourself a Website or Blog

04. Put your band's video on YouTube

05. Join Twitter, start following, post what's happening

06. Join Facebook, start wall posting

07. Put your URL on everything
In addition to the above mentioned  facts you can start your own blogs and for your links in the blog you can add adf.ly links ex;- software down load page.and also you can upload YouTube videos and put adf.ly links.

Monday, November 19, 2012

PHP switch statement in user management

PHP switch statement in user management

php switch statement can be used in user management First create database table  as bellow

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(60) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(60) NOT NULL,
  `pass_word` varchar(60) NOT NULL,
  `user_type` varchar(40) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
Then create bellow HTML file

<form id="loginForm" name="loginForm" method="post" action="check_login.php">
            <label>Username</label><br>
            <input size="30" name="user_name" type="text"><br>
            <label>Password</label><br>
            <input size="30" name="pass_word" type="password"><br>
            <label>User Type</label><br>
            <select name="user_type">
                                <option value="1">User1</option>
                                <option value="2">User2</option>
                                <option value="3">User3</option>
                
                                <option value="3">User4</option>
                                <option value="4">User5</option>
                                </select><br>
            <input value="Submit" type="submit">
</form>
Then create check_login.php

<?php
 
    session_start();
 
 
    require_once('dbcon.php');
 
 
    $errmsg_arr = array();
 

    $errflag = false;
 
 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }
 
    //Select database
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
        die("Unable to select database");
    }
 
 
    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }
 
 
    $user_name = clean($_POST['user_name']);
    $pass_word = clean($_POST['pass_word']);
   $user_type = clean($_POST['user_type']);
    //Input Validations
    if($user_name == '') {
        $errmsg_arr[] = 'Login ID missing';
        $errflag = true;
    }
    if($pass_word == '') {
        $errmsg_arr[] = 'Password missing';
        $errflag = true;
    }
   if($user_type == '') {
        $errmsg_arr[] = 'User Type missing';
        $errflag = true;
    }
    //If there are input validations, redirect back to the login form
    if($errflag) {
        $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        session_write_close();
        header("location: login_form.php");
        exit();
    }
 
 
    $qry="SELECT * FROM users WHERE (user_name='$user_name' AND pass_word='".md5($_POST['pass_word'])."' AND user_type='$user_type')";
    $result=mysql_query($qry);
 
    switch($user_type){
case 1:
    //Check whether the query was successful or not
        if($result){      
    if(mysql_num_rows($result) == 1){
        //Login successful
            session_regenerate_id();
            $login = mysql_fetch_assoc($result);
            $_SESSION['SESS_username'] = $login['user_name'];
            $_SESSION['SESS_usercategory'] = $login['pass_word'];
            $_SESSION['SESS_password'] = $login['user_type'];
          
            session_write_close();
            header("location: upload1.php");
               exit();
            }else {
            //Login failed
            header("location: login_failed.php");
            exit();
            }
        }
       break;
     
case 2:
    //Check whether the query was successful or not
 if($result){      
          if(mysql_num_rows($result) == 1){
        //Login successful
            session_regenerate_id();
           $login = mysql_fetch_assoc($result);
            $_SESSION['SESS_username'] = $login['user_name'];
            $_SESSION['SESS_usercategory'] = $login['pass_word'];
            $_SESSION['SESS_password'] = $login['user_type'];
            session_write_close();
            header("location: upload2.php");
               exit();
            }else {
            //Login failed
            header("location: login_failed.php");
            exit();
            }
        }
     break;
   
case 3:
    //Check whether the query was successful or not
    if($result){      
    if(mysql_num_rows($result) == 1){
        //Login successful
            session_regenerate_id();
           $login = mysql_fetch_assoc($result);
            $_SESSION['SESS_username'] = $login['user_name'];
            $_SESSION['SESS_usercategory'] = $login['pass_word'];
            $_SESSION['SESS_password'] = $login['user_type'];
          
            session_write_close();
            header("location: upload3.php");
               exit();
            }else {
            //Login failed
            header("location: login_failed.php");
            exit();
            }
        }
     break;
    
case 4:
    //Check whether the query was successful or not
        if($result){      
    if(mysql_num_rows($result) == 1){
        //Login successful
            session_regenerate_id();
            $login = mysql_fetch_assoc($result);
            $_SESSION['SESS_username'] = $login['user_name'];
            $_SESSION['SESS_usercategory'] = $login['pass_word'];
            $_SESSION['SESS_password'] = $login['user_type'];
          
            session_write_close();
            header("location: upload4.php");
               exit();
            }else {
            //Login failed
            header("location: login_failed.php");
            exit();
            }
        }
       break;
     
case 5:
    //Check whether the query was successful or not
 if($result){      
          if(mysql_num_rows($result) == 1){
        //Login successful
            session_regenerate_id();
           $login = mysql_fetch_assoc($result);
            $_SESSION['SESS_username'] = $login['user_name'];
            $_SESSION['SESS_usercategory'] = $login['pass_word'];
            $_SESSION['SESS_password'] = $login['user_type'];
            session_write_close();
            header("location: upload5.php");
               exit();
            }else {
            //Login failed
            header("location: login_failed.php");
            exit();
            }
        }
     break;
default:die("Query failed");
     exit();
    }
       
?>