By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

How to execute PHP

P: n/a
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.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jens wrote:
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)


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, <de*****@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Jul 17 '05 #2

P: n/a
Jens wrote:
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 That can't be done, because a HTML file never reaches a PHP processor.
to insert a text
file, but how do I execute the PHP without the form + post?

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"
Jul 17 '05 #3

P: n/a
Got you! I have seen the light.

Thanks,

Jens.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.