PDA

View Full Version : including a .htm file using an absolute URL?


belledumonde
08-18-2006, 06:35 AM
hello! i've done some searches on this but most of the stuff i find are to do with including dynamic files and other such advanced PHP which i neither understand nor need. im just a beginner with PHP and actually, this is all im using it for.

so my question is, can i include a .htm file if its on a different server as the php file?

im doing it this way because my hosting service doesnt allow SMTP, and the service i hosted the PHP script on, has ads and ruins everything.

here's the relevant part of the script:


if(!$name) {
include "header.htm";
echo "<p> <span class=\"warning\">Please provide your name

so that we know who you are;</span><br />
and kindly enter a valid e-mail

address so we can get back to you.</p>\n";
include "form2.htm";
} else if(!$email) {
include "header.htm";
echo "<p>Please provide your name so that we know who

you are;<br /> and <span class=\"warning\">kindly enter a valid

e-mail address so we can get back to you.</p>\n";
include "form2.htm";


where it says include "header.htm"; and include "form2.htm" i want to include files hosted on a different server. i tried doing include "http://taglehomes.awardspace.com/header.htm", same for the form2.htm, but it doesnt work.

how do i make it work?
thanks:)

kehers
08-18-2006, 10:31 AM
The error may be due to a couple of reasons. For example allow_url_fopen may not be enabled in ur php configuration (check ur phpinfo) to verify this.
If its not, then including a file from another server may not be such feasible AFAIK

belledumonde
08-18-2006, 11:21 AM
where do i check the php info? if allow_url_fopen is enabled, then i can or i might be able to?

thanks! :)

kehers
08-18-2006, 12:43 PM
simply run the script

<?php
phpinfo();
?>

from the content echoed out on the screen, simply search for allow_url_fopen (using ctrl-F on IE). If turned off, if you are using a PHP version <= 4.3.4, you can turn it on using ini_set:

<?php
ini_set('allow_url_fopen', 1);
//the rest of ur scripts
?>

if the php version is less than 4.3.4, it can only be turned on from the php.ini which u most certainly dont av access to if on a shared host.
Please note:
1. The configuration option set by ini_set will keep this new value during the script's execution, and will be restored at the script's ending
2. My posts here are not tested, so 100% of its efficiency is not guaranteed. :D However, post back if there is still further problems

kiwibrit
08-18-2006, 08:17 PM
Wouldn't most ISPs prevent access from another server?