Welcome, Guest
  • Author Topic: Guest book not working in php 5  (Read 1709 times)

    manoj

    • Server what's that
    • *
    • Posts: 2
      • View Profile
      • Email
    Guest book not working in php 5
    « on: 05/29/12, 08:56 »
    The guest book shows

    loading...

    +++++++++++

    <?
    ############### .::Comments are indicated by the # symbol - you can erase all of these if needed.
    ############### .::Author: Jeffrey F. Hill
    ############### .::Website: www.Flash-dB.com
    ############### .::If you have any questions either post them in the Flashkit Scripting & Backend Message board - or visit Flash-db.com and email me.

    ############### Begin GuestBook Script #####################################

    ##The first 3 lines use a regular expression to match a pattern then replace it with nothing.  The only reason for this is so we only allow necessary characters to be entered into the guestbook. This also takes out slashes which are sometimes added in the post headers to make the string friendly.  You can erase or take these lines out if you want.

       $Submit = $HTTP_POST_VARS['Submit'] ;
       $Email = $HTTP_POST_VARS['Email'] ;
       $Name = $HTTP_POST_VARS['Name'] ;
       $Comments = $HTTP_POST_VARS['Comments'] ;
       $Website = $HTTP_POST_VARS['Website'] ;
       $filename = $HTTP_POST_VARS['GuestBook.txt'];
       $NumHigh = $HTTP_POST_VARS['NumHigh'];
       $NumLow = $HTTP_POST_VARS['NumLow'];
       $GuestBook = $HTTP_POST_VARS['GuestBook'];
       //$Input = $HTTP_POST_VARS['Input'];
       $TotalEntries = $HTTP_POST_VARS['TotalEntries'];
       
       

       $Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
       $Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
       $Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);

       $Website = eregi_replace("http://", "", $Website);
       $Website = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);

       $Name = stripslashes($Name);
       $Email = stripslashes($Email);
       $Website = stripslashes($Website);
       $Comments = stripslashes($Comments);

    ####################################################################################
    ########### Reading and Writing the new data to the GuestBook Database #############


       
    if ($Submit == "Yes") {
    #Next line tells the script which Text file to open.
       $filename = "GuestBook.txt";

    #Opens up the file declared above for reading

       $fp = fopen( $filename,"r");
       $OldData = fread($fp, 80000);
       fclose( $fp );

    #Gets the current Date of when the entry was submitted
       $Today = (date ("l dS of F Y ( h:i:s A )",time()));

    #Puts the recently added data into html format that can be read into the Flash Movie.

       $Input = "Name: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></b></u><br>Website: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></b></u><br>Comments: <b>$Comments</b><br><i><font size=\"-1\">Date: $Today</font><br><br>.:::.";

    #This Line adds the 'GuestBook=' part to the front of the data that is stored in the text file.  This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file

       $New = "$Input$OldData";

    #Opens and writes the file.

       $fp = fopen( $filename,"w+");
       fwrite($fp, $New, 80000);
       fclose( $fp );
    }
    ####################################################################################
    ########## Formatting and Printing the Data from the Guestbook to the Flash Movie ##

    #Next line tells the script which Text file to open.
       $filename = "GuestBook.txt";

    #Opens up the file declared above for reading

       $fp = fopen( $filename,"r");
       $Data = fread($fp, 80000);
       fclose( $fp );

    #Splits the Old data into an array anytime it finds the pattern .:::.
       $DataArray = split (".:::.", $Data);

    #Counts the Number of entries in the GuestBook
       $NumEntries = count($DataArray) - 1;

       print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
       for ($n = $NumLow; $n < $NumHigh; $n++) {
       print $DataArray[$n];
          if (!$DataArray[$n]) {
          Print "<br><br><b>No More entries. </b>";
          exit;
          }
       }
       


    ####################################################################################
    ###############  End GuestBook Script
    ?>

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Guest book not working in php 5
    « Reply #1 on: 05/29/12, 09:22 »
    As you propably overseen - the php code is for php 3.
    It needs some adaption.

    $HTTP_POST_VARS is now $_POST
    ereg_replace does not exist anymore - you must use preg_replace instead

    This tutorial is a little outdated (about 10 years old).
    happy flashing
    8)
    Ronald

    manoj

    • Server what's that
    • *
    • Posts: 2
      • View Profile
      • Email
    Re: Guest book not working in php 5
    « Reply #2 on: 05/29/12, 11:41 »
    Thanks for your response

    tried the following, same error
    ++++++++


    $Submit = $_POST['Submit'] ;
       $Email = $_POST['Email'] ;
       $Name = $_POST['Name'] ;
       $Comments = $_POST['Comments'] ;
       $Website = $_POST['Website'] ;
       $filename = $_POST['GuestBook.txt'];
       $NumHigh = $_POST['NumHigh'];
       $NumLow = $_POST['NumLow'];
       $GuestBook = $_POST['GuestBook'];
       //$Input = $HTTP_POST_VARS['Input'];
       $TotalEntries = $_POST['TotalEntries'];
       
       

       $Name = preg_replace("[^A-Za-z0-9 ]", "", $Name);
       $Email = preg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
       $Comments = preg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);

       $Website = preg_replace("http://", "", $Website);
       $Website = preg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Guest book not working in php 5
    « Reply #3 on: 05/30/12, 05:38 »
    What happens, if you call this script in your browser?
    Did you check the comminication with charles? http://www.charlesproxy.com/
    Do you have a life link, where we can have a look?
    happy flashing
    8)
    Ronald