Jump to content

Recommended Posts

I am trying to display the content of a text (txt) to the browser. It displays the bold item (title of the page).

then it displays the Date Date Date Date.

 

Please Help!

 

function Guestbk_3() {
  // Display Guestbook Entries to Browser
  global $Date, $Pastor, $Webmaster, $Name, $Church, $City, $State, $Comments, $Alladdresses;
  $MyFile = "guestbook.txt";
  $fh = fopen($MyFile,"r");
  rewind($fh);
  if(!$fh) {
   die("couldn't open file <i>$MyFile</i>");
  }
  else {
   $file = file_get_contents("$MyFile");
  }
  fclose($fh);
  if(strstr($file,$Date)) { 
   echo "<html>\n";
   echo " <head>\n";
   echo " <title>Guestbook Entries</title>\n";
   echo " </head>\n";
   echo " <body BGCOLOR=\"blue\" TEXT=\"white\">\n"; 
   echo " <table align=\"center\">\n";
   echo " <tr>\n";
   echo " <td align=\"center\">\n";
   [b] echo " <font size=\"+2\">~ ~ ~ GUESTBOOK ENTRIES ~ ~ ~</FONT>\n";[/b]
   echo " <br /><br />\n";
   echo " </td>\n";
   echo " </tr>\n";
   echo " </table>\n";
   echo " <table align=\"center\" width=\"600\">\n";
   echo " <tr>\n";
   echo " <td align=\"left\">\n";
[b]   echo " $file\n";[/b]
   echo " </td>\n";
   echo " </tr>\n";
   echo " </table>\n";
   echo " </body>\n";
   echo " </html>";
  }
}

 

Link to comment
https://forums.phpfreaks.com/topic/184482-display-string-content-to-browser/
Share on other sites

I looked at the file and this is what it looks like:

 

 

Mon  07 Dec 2009

 

,

 

 

 

Mon  07 Dec 2009

 

,

 

 

 

Tue  08 Dec 2009

 

,

 

 

 

Tue  08 Dec 2009

 

I do not understand why the other information was not written to the file.  the function Guest_bk() should have written the information to the file guestbook.txt

 

//FUNCTIONS 
function Guestbk_1(){
  // write to file guestbook.txt
  global  $Date, $Name, $Church, $City, $State, $Comments;
  $MyFile = "guestbook.txt";
  $fh = fopen($MyFile,'a+');
  if(!$fh) {
   die("couldn't open file <i>$MyFile</i>");
  }
  else {
   rewind($fh);
   $str = "\n";
   $str.= "\t\t\t\t\t$Date\n";
   $str.= "\t\t\t\t\t$Name\n";
   $str.= "\t\t\t\t\t$Church\n";
   $str.= "\t\t\t\t\t$City\n";
   $str.= "\t\t\t\t\t$State\n";
   $str.= "\t\t\t\t\t$Comments\n"; 
   $str.= "\n"; 
   fwrite($fh, $str);
   echo "success writing to file";
  }
  fclose($fh);
}

function Guestbk_3() {
  // Display Guestbook Entries to Browser
  $MyFile = "guestbook.txt";
  $fh = fopen($MyFile,"r");
  rewind($fh);
  if(!$fh) {
   die("couldn't open file <i>$MyFile</i>");
  }
  else {
   $file = file_get_contents("$MyFile");
  }
  fclose($fh);
  if(strstr($file,$Date)) { 
   echo "<html>\n";
   echo " <head>\n";
   echo " <title>Guestbook Entries</title>\n";
   echo " </head>\n";
   echo " <body BGCOLOR=\"blue\" TEXT=\"white\">\n"; 
   echo " <table align=\"center\">\n";
   echo " <tr>\n";
   echo " <td align=\"center\">\n";
   echo " <font size=\"+2\">~ ~ ~ GUESTBOOK ENTRIES ~ ~ ~</FONT>\n";
   echo " <br /><br />\n";
   echo " </td>\n";
   echo " </tr>\n";
   echo " </table>\n";
   echo " <table align=\"center\" width=\"600\">\n";
   echo " <tr>\n";
   echo " <td align=\"left\">\n";
   echo " $file\n";
   echo " </td>\n";
   echo " </tr>\n";
   echo " </table>\n";
   echo " </body>\n";
   echo " </html>";
  }
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.