<html>
<head>
<title>Display a local file or url</title>
<style type="text/css">
<!--
#Layer3 {
        position:relative;
        left:60px;
        top:10px;
        width:650px;
        height:110px;
}
.style4 {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 16px;
        font-weight: bold;
}
-->
</style>
</head>

<body bgcolor="lightyellow">
<?php

//  include "get.php";                                        //include get functions
    include "/home/sultans/web/php/demo/7adv/get.php";        //to make it work with PHP*Tester

    if($_POST)
        validate();

    display();

//------------------------------------------------------------------------------------------------------
function validate()
{
        global $filename, $msg, $data;

        $filename  = $_POST['file'];
        
        if ($filename == '') {
                $msg = '*** Please enter a file name ***';
                return;
        }

        $data = getFile($filename);			#get the file into a string         
}

//------------------------------------------------------------------------------------------------------
function display()
{       
        global $filename, $msg, $data;
        
        
        print "<div id='Layer3'> \n";
        print "<form METHOD=post ACTION=getFile2.php> \n";        
        
        print "<fieldset style='width:650'> \n";
        print "<legend>Retrieve a Local File</legend> \n"; 

        print "<table border='0'> \n";

        print "<tr>";
        print "<td> File Name </td> \n";
        print "<td><input type='text' name='file' value='$filename' size='55'/> ";
        print "(absolute path) \n";
        print "</tr>";
        print "<tr>";
        print "<td></td>";
        print "<td><input type='submit' value='  Retrieve  '>";
        print "<font color='red'> $msg </font></td> \n";
        print "</tr>";
        print "</table>";       
        print "</fieldset>";
        print "</form> \n";
        print "</div>  \n";
        print "<hr />  \n";
               
        $data = nl2br($data);                               //replace '\n' with <br>

        print $data;
}
?>
</div>

<?php include "../include.php"; ?>              <!-- hyperlink to see the code -->
</body>
</html>