How to execute PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jens

    How to execute PHP

    This is a way too abvious newbie question but nevertheless a
    showstopper. I know how I can get a PHP script to execute by having a
    form with a post method in my regular HTML file. So far so good.

    Now I just want to run a PHP scrip from an HTML file to insert a text
    file, but how do I execute the PHP without the form + post?

    (The text file is a club member list and I want the web page to always
    display the updated list)

    Thanks,

    Jens.

  • Jan Pieter Kunst

    #2
    Re: How to execute PHP

    Jens wrote:[color=blue]
    > This is a way too abvious newbie question but nevertheless a
    > showstopper. I know how I can get a PHP script to execute by having a
    > form with a post method in my regular HTML file. So far so good.
    >
    > Now I just want to run a PHP scrip from an HTML file to insert a text
    > file, but how do I execute the PHP without the form + post?
    >
    > (The text file is a club member list and I want the web page to always
    > display the updated list)[/color]

    Shortest way I can think of, just showing the contents of memberlist.txt
    without HTML.

    <?php

    header('Content-type: text/plain);
    readfile('/path/to/memberlist.txt' );

    ?>

    I'm sure you can figure it out from here.

    JP

    --
    Sorry, <devnull@cauce. org> is a spam trap.
    Real e-mail address unavailable. 5000+ spams per month.

    Comment

    • Hans van Kranenburg

      #3
      Re: How to execute PHP

      Jens wrote:[color=blue]
      > This is a way too abvious newbie question but nevertheless a
      > showstopper. I know how I can get a PHP script to execute by having a
      > form with a post method in my regular HTML file. So far so good.
      >
      > Now I just want to run a PHP scrip from an HTML file[/color]
      That can't be done, because a HTML file never reaches a PHP processor.
      [color=blue]
      > to insert a text
      > file, but how do I execute the PHP without the form + post?[/color]
      Just call it .php instead of .html, and make sure php commands are
      between <?php and ?>. Everything outside <?php ?> will not be parsed by
      the php interpreter. Call the .php file directly from your browser.

      E.g. foobar.php:

      <html>
      <head></head>
      <body>

      <?php
      include "members.tx t";
      ?>

      Some other <b>HTML</b>

      <?php
      # some other php etc. etc.
      ?>

      </body>
      </html>

      Hans

      --
      "He who asks a question is a fool for five minutes;
      he who does not ask a question remains a fool forever"

      Comment

      • Jens

        #4
        Re: How to execute PHP

        Got you! I have seen the light.

        Thanks,

        Jens.

        Comment

        Working...