I was wondering if I could use PHP to embed my CGI Email form in my index page. My host requires that I put my CGI script in a special folder (CGI wrapper) so including it on the index page is not possible unless I embed it somehow. I really don’t want to use an iframe. Can I accomplish this with PHP? Could someone provide an example?
And there's no extra coding for the page to be embedded(In this example the page called "form.html")?
I ended up using an ajax and it works fine but if my host will allow me to do this instead I think it'd be a better way to go (no JS). Thanks for your help PHPSHIFT2.
I contacted my host and they said it's supported, but I'm still unable to get it to work. I read this somewhere: "The way PHP handles the ./ and ../ is totally counter intuitive." But they didn't really elaborate.
If my parent html file (index.html) is in the root and I want to access a file that's in a folder in the root, normally I'd write the path like this: "folder/form.html". Is the path different in PHP?
Well, "./" stays in the same directory while "../" goes up one directory. It's pretty simple. Let's say you were in "yoursite.com/dir/subdir" and you wanted to include the file "yoursite.com/dir/difdir/form.html". You'd just do this:
Thanks again PHPSHIFT2, but it appears my troubles are with my host and not my code. I tried this a million different ways (PHP, ASP, ISS) and it still isn't working. I notified my host and they're dumbfounded. I think the trouble is that PHP support hasn't been activated on my account, but I've looked all through my CPanel and can't find where I need to activate it. So I'm hoping the support folks can steer me in the right direction. To try to weed out the problem I uploaded two test files to the same directory and used the path "./red.html" and it's not working.
Question: ./ = this directory and ../ = up one directory so ./folder/file.html will look in the current directory for a folder and then inside that one for the file, right?
That's the path I'll need to take if support can figure out why my account is malfunctioning.
From your original question, my understanding is that the page that you are trying to include is a CGI script, then including it via "include()" will not really work because the only processing that will be applied to it will be PHP and not whatever CGI Handler has been defined on the web server. The reason is that PHP does a local file system read on the file and then applies PHP rules to whatever it finds in there. If it's non-PHP, it will just output as-is whatever it finds.
You may not like it, but ultimately, you may have to resort to a <frame> or <iframe> to get the CGI script to run as it should and display the results in a semi-controlled fashion.
There could be another way, which would be to use the so-called "Apache-specific Functions" (see: http://www.php.net/manual/en/ref.apache.php), but I've never done it so I'm not going down that road. But perhaps someone else has experience with it...
Bookmarks