Forum Moderators: coopster

Message Too Old, No Replies

PHP Includes: Include a .cgi file?

Please tell me it can be done

         

MatthewHSE

4:51 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know very little about PHP, but I'm using a PHP form processor on my site. The form processor has an error page coded into the PHP file, where people are taken if they didn't fill in required fields. In order to make the error page match the rest of my site, I've got to be able to include a header and a footer, which are normally inserted with a server side include. But the both SSI's are .cgi files. Is there any way I can get them included in that PHP error page?

Thanks,

Matthew

DrDoc

6:00 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can run them through the exec/system function, and echo the output... You can't, however, use the include function.

NameNick

9:32 am on Oct 31, 2003 (gmt 0)

10+ Year Member



Matthew,

You can use the function virtual [de2.php.net]().

virtual() is an Apache-specific function which is equivalent to <!--#include virtual...--> in mod_include. It performs an Apache sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you would parse through Apache...

NN

MatthewHSE

3:26 pm on Oct 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do either of you know of a good online resource that will provide detailed information about using either of the methods you suggested? I tried the virtual() method, but couldn't make it work. Couldn't make head nor tail out of the other method, but it sounds interesting.

I simply MUST learn PHP soon. The more I read about it the more I'm amazed!

The error page I mentioned in my first post is printed like this:

function display_errors($errors){
$errors = '<li>' . join('<li>', $errors);

print <<<EOF

<html> ... </html>

EOF;
}

How would I use either the virtual() or the exec/system and echo method in this scenario?

And do you know a good PHP resource for a complete know-nothing? I know HTML and CSS pretty well, but absolutely no scripting. So a good beginners book on PHP would be a good thing for me to have.

Thanks,

Matthew

gethan

3:39 pm on Oct 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't used this but have a hunch that;

$footer = implode('',file('http://www.yourdomain.com/footer.cgi?your=arg'));

Would do what you are looking for quickly and easily. BUT it is not to pretty.

Find the right place in the form processor to print $footer and $header and that's all there will be to it.

Good online tutorial - [php.net...]

I suggest your first project would be to write header and footer replacements ;) Shouldn't be hard at all.

Good luck.

DrTebi

11:20 pm on Nov 2, 2003 (gmt 0)

10+ Year Member



Hello,
as for learning PHP, I have always liked the tutorials at DevShed:
[devshed.com...]

If that's not enough for you, you can find a ton of turials here:
[devarticles.com...]

I also highly recommend that you download the CHM help from PHP.net. It's your best friend when coding PHP, I use it every day. Grab it here:
[php.net...]

And now start coding :)