How To Trace Dynamic Page URL In PHP

// FUNCTION Starts ….

function getPageURL()

{

$pageURL = ‘http’;
if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER["SERVER_PORT"] != “80″) {
$pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

}

Note : Use This Funtion To Get The Dynamic Page URL.

Problemes With Iframe. And it’s solution

When we REFRESS web page containing IFRAME, the page reloades with the starting page. Here is the solution being in the existing page after refress. (PHP Script)

Generally what happens, when we refress a web page containing IFRAME ? The page reloades with the starting page. Information provided in the existing page are lost. this is a big problem with Iframe. Here is a way to solve this problem in php script, the can be solved in any scripting languages. See it and try ….

STEP 1: First declare a iframe in aweb page. Let the name of the web page be index.php

            <iframe src=”<?php echo $_COOKIE['pagename']; ?>” width=”738″ height=”500″ frameborder=”0″ name=”second”                 scrolling=”Yes”></iframe>

STEP 2: Now I want to load process.php page in that iFrame when I click on the submit button in index.php page.

             <?php

                     header(‘Location: process.php’);

            ?>

STEP 3:  Now insert the following code in the process.php page.

            <?php

                     ob_start();

                     setcookie(‘pagename’, ‘process.php’);

                     // Please never forget to recover the values using $_GET['']

            ?>

Now See the magic. Now press F5 To refress the page. You will see that the the Iframe will reload with the existing page.

Note : If you have got any problem with web programming then sent your message as comment with your email. Coder Circle is ready for you…

How To Access Cookie Without any special Charecters

Generally, when we access javascript, wild card charecters are replaced by some special symbols (like +,% etc). This code is for accessing cookie value withour any special chacters. Try It.

//Reading Cookie

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
 var cookiename = n+ ‘=’;
 var cookiebegin = document.cookie.indexOf(cookiename);
 var cookieend = 0;
 if(cookiebegin > -1) {
  cookiebegin += cookiename.length;
  cookieend = document.cookie.indexOf(“;”,cookiebegin);
  if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
  cookiecontent = document.cookie.substring(cookiebegin,cookieend);
 
  }
 }
return unescape(cookiecontent);
} //  This Code is for reading cookie value. But the output will consist of  ‘+’ sign in the place wild card charecters. To remove this ‘+’

//use the following function.

function get_body()
 {
  var ind = document.form2.lstmessage.selectedIndex;
      var string=ReadCookie(ind);
      var strReplaceAll = string;
      var intIndexOfMatch = strReplaceAll.indexOf( “+” );
 
      // Loop over the string value replacing out each matching
      // substring.
      while (intIndexOfMatch != -1){
      // Relace out the current instance.
       strReplaceAll = strReplaceAll.replace( “+”, ” ” );
 
      // Get the index of any next matching substring.
      intIndexOfMatch = strReplaceAll.indexOf( “+” );
      }
 
      //alert( strReplaceAll );
      document.form2.txtbody.value = strReplaceAll;    
 }
Cookies in Javascript

/ _________________Function To Create Cookie In Javascript____________________ //
function createCookie(name,value,days) {
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000))
      var expires = “; expires=”+date.toGMTString()
      }
      else var expires = “”
      document.cookie = name+”=”+value+expires+”; path=/”;
 }
 
// _________________Function To Read Cookie In Javascript____________________ //
 
function ReadCookie(n) {
  var cookiecontent = new String();
 if(document.cookie.length > 0) {
 var cookiename = n+ ‘=’;
 var cookiebegin = document.cookie.indexOf(cookiename);
 var cookieend = 0;
 if(cookiebegin > -1) {
  cookiebegin += cookiename.length;
  cookieend = document.cookie.indexOf(“;”,cookiebegin);
  if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
  cookiecontent = document.cookie.substring(cookiebegin,cookieend);
 
  }
 }
return unescape(cookiecontent);
} // function ReadCookie()
 
Note : If The cookie contents consist of some ‘+’ symbol then use the following code to filter the cookie contect. The
Following function is to remove the + symbols from the cookie content. It can be used for removing other special charecters from the cookie content. To use the following code to remove other special charecters, simple replace the ‘+’ symbol by the special symbol in star(//***********************//) marked line..
 
      var string=ReadCookie(ind);
      var strReplaceAll = string;
      var intIndexOfMatch = strReplaceAll.indexOf( “+” ); //***********************//
 
      // Loop over the string value replacing out each matching
      // substring.
      while (intIndexOfMatch != -1){
      // Relace out the current instance.
       strReplaceAll = strReplaceAll.replace( “+”, ” ” );
 
      // Get the index of any next matching substring.
      intIndexOfMatch = strReplaceAll.indexOf( “+” );
      }
 
 
Author – Dhiraj Das
From – Skillhut

Handling forms in Javascript

This lesson will give an idea how to start using javascripts in forms

<HTML>
<BODY>
<SCRIPT LANGUAGE=javascript>
<!–
     function f1(){
     document.write(MyForm.name,”<Br>”,MyForm.textname.value,”<Br>”,MyForm.length)
     }
//–>
</SCRIPT>
</BODY>
<FORM action=”" method=POST name=MyForm onclick=”f1()”>
<INPUT type=”text” name=textname value=”Broken Arrow”>
</FORM>
</HTML>

Iteration in JavaScript

A lesson for the beginners – how to use iteration in Javascript

<html>
<body>
<script>
   <!–
           b=1      
           while (b>6){
                b= document.write(b);b+1;
           }
           document.write(b,”<br>”);
      –>
</script>
</body>
</html>