Connecting Tech Pros Worldwide Forums | Help | Site Map

How to execute PHP

Jens
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Guest
 
Posts: n/a
#2: Jul 17 '05

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.
Hans van Kranenburg
Guest
 
Posts: n/a
#3: Jul 17 '05

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.txt";
?>

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"
Jens
Guest
 
Posts: n/a
#4: Jul 17 '05

re: How to execute PHP


Got you! I have seen the light.

Thanks,

Jens.

Closed Thread