<html>
<head>
<title>File handling</title>
</head>
<body bgcolor=#CCFFFF>
<h1>Managing a file</h1>
<table>
<form>
<tr><td>Please enter the filename <td><input name = yourfile    value="<?= $yourfile ?>">
<tr><td>Please enter the code     <td><input name = yourcode  value="<?= $yourcode ?>">
<tr><td><input type=submit>
</form>
</table>
<hr>
<?
if($yourfile){
    $yourcode = stripslashes($_REQUEST[yourcode]);
    $yourfile = stripslashes($_REQUEST[yourfile]);
    $linecount=0;
    $myString = "";
    $file = fopen($yourfile,"r") or die ("No such file $yourfile.\n");
    while(!feof($file)){
   $line = fgets($file,256);
   $linecount++;
   if(ereg($yourcode,$line)){
       $myString .= "<br> $line";
   }
    }
    fclose($file);
    print "<p>Your file is : $yourfile";
    print "<p>Your searchcode is : $yourcode";
    print "<p>And here are the $linecount matches:<p>";
    print $myString;
}

?>





-- PeterJones - 08 Nov 2006

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2006-11-08 - PeterJones
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback