Translate

Thursday 10 October 2013

PHP Server Variable using foreach Condition

index.php:

<?PHP

foreach($_SERVER as $key_name => $key_value) {

print $key_name . " = " . $key_value . "<br>";

}

?>
 
In this coding foreach Condition is used to which Browser the user is to working and 
which remote address &IP address all information is to be display. 

Wednesday 9 October 2013

Server Variables in PHP to find the Referrer,Browser&IP Address

Coding:

<?php
$referrer = $_SERVER['HTTP_REFERER'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$ipAddress = $_SERVER['REMOTE_ADDR'];

print "Referrer = " . $referrer . "<BR>";
print "Browser = " . $browser . "<BR>";
print "IP Adress = " . $ipAddress;
?>
 
In the above coding is usefull to find out which browser the user is to be working 
on&which ip address&which referrer (i.ein which domin&folder the user is working).
Try this Script. 

Tuesday 8 October 2013

Trim Function Coding

Coding:

<?PHP

//$space = "creatersite";
$space = trim(" hello ");//trim() is to remove space
$letCount = strlen($space);
print $letCount;

?>
 
In this Coding why we have to use trim function to remove the space between the letters
and characters 
$space = trim(" hello ");
We didn't use the trim function we can see that there is extra space before and after 
the text take and count the length.$space = "creatersite";
Try this script 

Sunday 6 October 2013

To View PDF File in Lightbox Using CSS&Javascript

Screenshot:
                                       
Explanitation:
                                         In this concept Like an Light box only.In Light box concept if u click an option that image will be viewed zoom that image.Likewise in the same concept i'll give coding for to view/display the PDF File in an lightbox concept.

index.php:

<html>
<link href="style2.css" rel="stylesheet"/>
<link href="style1.css" rel="stylesheet"/>
<script type="text/javascript" src="j.js"></script>
<script type="text/javascript" src="j1.js"></script>
</head>
<body>
<a style="width:144px;" href="parameters1.pdf" id="fb_26" class="demo" data-fb-options="className:floatbox;caption:href;">
<img id="fb_27" class="plain" src="pdf_108.jpg" alt="" height="108" width="144"></a>
</body>
</html>

Download CSS:style1.css,style2.css
Download js :j.js,j1.js

Thursday 3 October 2013

Onload pointer in field using Javascript

Screenshot:

                                                
index.php:

<body id="bdy" onload="document.contactform.name.focus();"></body>
contactform-->formname,
name-->fieldname


onload="document.contactform.name.focus();" we have to put this coding in inside the <body>tag.
contactform-->formname
name       -->fieldname      

Innerhtml Validation for a Form

Screenshot:
                       
index.php:

<form name="form1" method="post" onsubmit="return validation();">
<table width="30%" border="0" cellspacing="0" cellpadding="5" id="tbl">
  <tr>
    <td width="226" scope="col"><label for="first3">Firstname</label></td>
    <td width="248" scope="col"><input type="text" name="first" id="first3" /></td>
   <td width="30%" id="fname"></td>
  </tr>
  <tr>
    <td width="226" scope="col"><label for="last"> Lastname</label></td>
    <td width="248" scope="col">  <input type="text" name="last" id="last" /></td>
    <td width="30%" id="lname"></td>
  </tr>
  <tr>
    <td align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Submit" /> </td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

validation.js:


function validation()
{

var nae=document.form1.first.value;
    if(nae=="" || nae=="null") 
    {
        document.getElementById('fname').innerHTML="Enter Firstname";
        document.getElementById('lname').innerHTML="";
        
        document.form1.first.focus();
        return false;
    }
    
    var nme=document.form1.last.value;
    if(nme=="" || nme=="null") 
    { 
        document.getElementById('fname').innerHTML="";
        document.getElementById('lname').innerHTML="Enter Lastname";
        
        document.form1.last.focus();
        return false;
    }
}