/    Sign up×
Community /Pin to ProfileBookmark

Can I use PHP rather than an Iframe?

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?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@phpshift2Dec 25.2006 — Yes. Just use a PHP include. Let's say I wanted to include form.html on index.php...

<i>
</i>&lt;?php include("form.html"); ?&gt;


Simple as that. ?
Copy linkTweet thisAlerts:
@bustyaauthorDec 27.2006 — So it's size is defined by the element it's embedded in? Let's say:

<div style="width:300px; height:300px;">

<?php include("form.html"); ?>

</div>

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.
Copy linkTweet thisAlerts:
@bustyaauthorDec 27.2006 — 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?
Copy linkTweet thisAlerts:
@aussie_girlDec 27.2006 — I would use [code=php]<?PHP include('./folder/form.html');?>[/code]
Copy linkTweet thisAlerts:
@phpshift2Dec 27.2006 — 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:
[code=php]
<div style="width: 300; height: 300; overflow: auto; ">
<?php include("../difir/form.html"); ?>
</div>
[/code]


?
Copy linkTweet thisAlerts:
@bustyaauthorDec 28.2006 — 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.
Copy linkTweet thisAlerts:
@aussie_girlDec 28.2006 — try renaming it to testphp.php not html
Copy linkTweet thisAlerts:
@phpshift2Dec 28.2006 — try renaming it to testphp.php not html[/QUOTE]

Precisely. Name it testphp.php. ? Simple solution. ?
Copy linkTweet thisAlerts:
@NightShift58Dec 28.2006 — 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...
Copy linkTweet thisAlerts:
@bustyaauthorJan 15.2007 — try renaming it to testphp.php not html[/QUOTE]


Yep that was the issue, this was my first experience with PHP and I didn't realize. Thanks everyone.
×

Success!

Help @bustya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...