Greetings all once again.

I currently use two include statements in my html for stock page headers, style sheets, and footers, as follows:

[FONT=Courier New]<!--#include virtual="rtcheader.inc" -->[/FONT]
page-specific html code here in between the includes
[FONT=Courier New]<!--#include virtual="rtcfooter.inc" -->[/FONT]

I tried to use this in my sendmail PHP to make the "thank you" page look like the rest of the site. I used statements like:

[FONT=Courier New]print("<!--#include virtual="rtcheader.inc" -->");[/FONT]

but I got a parsing error.

Any thoughts on this one would be appreciated.

Tony

    For includes to work they must be in PHP. I am not sure about HTML you can reference a CSS or a JavaScript but with PHP it must be a PHP file. For instance lets say I have all my connection data in the below file;

    <?php
    $host="localhost";
    $user="username";
    $password="secret";
    $connect=mysql_connect($host.$user,$password)
      or die("could not connect to database server. MySQL said: ".mysql_error());
    ?>

    Then when I need this information to connect to the database I just include it like this;

    <?php
    include("connect.inc.php");
    $db=mysql_select_db("mydatabase",$connect)
      or die("Could not select the database. MySQL said: ".mysql_error());
    $query="SELECT * FROM records WHERE user='aUserName';
    //...more code
    ?>

    Now the way PHP will see the above is basically

    <?php
    $host="localhost";
    $user="username";
    $password="secret";
    $connect=mysql_connect($host.$user,$password)
      or die("could not connect to database server. MySQL said: ".mysql_error());
    $db=mysql_select_db("mydatabase",$connect)
      or die("Could not select the database. MySQL said: ".mysql_error());
    $query="SELECT * FROM records WHERE user='aUserName';
    //...more code
    ?>

      Sounds reasonable.

      To paraphrase, if I :
      (1) rename INCLUDE.INC to INCLUDE.INC.PHP; and
      (2) restructure INCLUDE.INC.PHP so that it has "PRINT" statements in it to output the html instead of containing only native html;

      I should be good to go, right? Or am I missing the point?

      Thank you.
      Anthony

        No need to make it PHP. If include.inc is a file with HTML, just do this:

        readfile('include.inc');

          Hmm, I never really thought about this but you could write the code as below

          <?php
          //Mostly HTML but might contain PHP variables
          //set some short variables from a form
          $email=$_POST['email'];
          $username=$_POST['username'];
          //and so on
          ?>
          <h1>Welcome from So and So website</h1>
          <div align="justify"> A whole bunch of html stuff and such as <?php echo $unsername ?>
          then more HTML .....
          then <?php echo $email ?> 

            The READFILE method worked perfectly! Thank you.

            Thank you, also, Houdini. I will try your approach as well, as I have a derivative script that this may be perfect for.

            FWIW, I have been tinkering and trying to get this script to work right and look right. After two days I found this forum, and success was found in just a few posts.

              Glad you had a good experience at PHPBuilder. Feel free to visit often and spread the word! 😉

                Write a Reply...