PDA

View Full Version : Using PHP to post to HTML


Office_Glen
05-29-2003, 09:44 PM
Please help me, I am TRYING to learn as I go here but I can't seem to get this stupid little function to work.

I have a random quote script for my website but can't figure out how to get the quote onto the webpage.

Am I supposed to put something on the page to make it run, or does it run the PHP script when it gets to the part in the HTML when it asks for it?

The script is called randquote.php

Please? Thanks.

Nightfire
05-29-2003, 09:54 PM
Can you post the code inside the php page?

Office_Glen
05-29-2003, 09:59 PM
<?php
/*
-- Random Quote Script 1.0 by Clarence Eldefors,webmaster@cerebuswebmaster.com
-- http://cerebuswebmaster.com

This script is free to use and modify. However it is not free to re-distribute
without written permission from the author.

Any comments or questions can be sent to webmaster@cerebuswebmaster.com.

There are only 3 things to change in this script. $font is the name of the font you
want the quotes to be written with. $fontsize is the size of the font, and $textfile
is the filename of the quotes file.

The quotes file need to have one quote on each line. See the quotes.txt distributed with this
file for an example.
*/

$font ="Arial"; // change to the font of your choice
$fontsize ="2"; // change to the font size of your choice
$textfile ="quotes.txt"; // change to the filename/path of your file with quotes.

//Do not change anything after this line
echo "<font face=\"$font\" size=\"$fontsize\">";
$quotes = file("$textfile");
$quote = rand(0, sizeof($quotes)-1);
echo $quotes[$quote];
echo "</font>";
?>

Nightfire
05-29-2003, 10:17 PM
Wherever you want the quote to show, can use (in a php page)

<?php include("randquote.php"); ?>

Office_Glen
05-29-2003, 10:29 PM
I am trying to make the result of the script appear on an existing HTML page, is this possible?

Nightfire
05-29-2003, 10:37 PM
Only way is if the server is set up to parse html files as php, but I don't know how/if it's possible. The only other way would be to use an iframe or similar

Office_Glen
05-29-2003, 10:40 PM
Okay I sent an email to my web support guys. Thanks for your input, I appreciate it.

Nightfire
05-29-2003, 11:04 PM
Well I've done a bit of looking around for you. In a .htaccess file, add the following:

AddType application/x-httpd-php .php .php3 .phtml .html

and upload that into your root directory, from what I've read, that should parse a html as php

Office_Glen
05-29-2003, 11:06 PM
Thanks again!

STDestiny
05-30-2003, 12:30 PM
If that doesn't work, (some ISP's disable htaccess) you can make another .php that outputs the quote as a javascript document.print() and then call the script using javascript.

-Andrew