View Full Version : Including Php file in an asp
Haidar
09-01-2010, 06:49 PM
Alright the big question is how can i include an php file in an asp.
I know there is the iframe function, but the thing is:
1 - The php file has the menu for my site
2 - The asp file has the whole site, design, and text.
So when i use the ifram method in the asp file. The menu will sit exactly correct, but when i click on the menu the effect wont take on the whole site, only in the iframe box. And i dont want that.
Any ideass? :confused:
Fou-Lu
09-01-2010, 08:06 PM
This cannot be done the way you think it can. These two pages are two completely different sources, and when you use your iframe its like a mini picture-in-picture of another location within yours. I don't believe that iframe contents can be targeted either.
You can use AJAX to perform this task, it can read in the external data and you can traverse the dom to get what you need. This does require JS enabled on the client though.
Another option is to scrape the page you are looking to grab the HTML from. This is easy to do in PHP, but I'm not sure about asp (and it sounds like your page is asp, so I'll move it into that forum as well).
The best solution, assuming you control both of these sites, is to create an XML feed for what you need. This allows you to easily retrieve it from either a server side solution or a client side one while minimizing the number of lookups required.
All of these cases involve scraping the html out of one location and adding it to another. There would no longer be an iframe involved.
Old Pedant
09-01-2010, 08:22 PM
I don't believe that iframe contents can be targeted either.
???
Why not??
<a target="_top" href="anotherPage.asp">click</a>
or
<form target="_top" href="yetAnother.asp">
...
</form>
Or is that not what you meant, FouLu??
Old Pedant
09-01-2010, 08:23 PM
Personally, I'd simply recode the menu in ASP, if the rest of the site is ASP.
Surely that wouldn't take more than an hour or two.
Fou-Lu
09-02-2010, 03:41 AM
Yeah I'm kinda curious why you'd bother myself, I'd just rewrite the small portion to match the current language instead of playing with two different types.
No, what I meant by the iframe itself is I don't think you can target where the inner frame goes. So from your .asp file you have an iframe with a php file in it, I don't think you can tell the links within that iframe to point at a different target like a new window or another iframe. Of course, if you have access to both sites, that's a completely different story, in which case you could easily do that by modifying the inner frame's targets.
Haidar
09-02-2010, 04:43 AM
Yeah I'm kinda curious why you'd bother myself, I'd just rewrite the small portion to match the current language instead of playing with two different types.
No, what I meant by the iframe itself is I don't think you can target where the inner frame goes. So from your .asp file you have an iframe with a php file in it, I don't think you can tell the links within that iframe to point at a different target like a new window or another iframe. Of course, if you have access to both sites, that's a completely different story, in which case you could easily do that by modifying the inner frame's targets.
That exactly what i want! I cant recode the menu code into asp, it's because the whole login form is in php, and i want the menu to be shown up only when users have signed in.
So i tried with iframe and it worked, but as you sayed here above, the links in the iframe wont point in diffrent target like a new iframe. Please is there any possible way? and if its can you explain to me the steps like old pedant always does :P because im really stupid when it comes to asp and php haha :D.
Haidar
09-03-2010, 11:01 AM
Anyone who can help me?:confused::confused::confused::confused:
Old Pedant
09-03-2010, 07:11 PM
Show some code. I don't really understand why you are having a problem. See my post #3. In what way is that NOT what you need???
oracleguy
09-03-2010, 07:13 PM
You could change your server configuration so the ASP pages are ran through the PHP engine after the ASP engine. However that would add a significant amount of overhead since all ASP pages would be subjected to this.
Why did you code your login page in PHP when the rest of your site is done in ASP? Login systems are trivial in both languages. Normalizing your code to ASP will save you a lot of grief since if you want any other features to work only when you login you are going to start to code yourself into a corner.
Old Pedant
09-03-2010, 07:32 PM
I think he's using a pre-canned PHP system for login and access control. I agree that rewriting it would make it all a lot simpler, but I still can't see why he can't use links in the <iframe> to control the main window, if it's all coded in JS.
Haidar
09-03-2010, 09:34 PM
The thing is i did download the php login script. I tried to find one in asp but i couldn't. But my page is coded by me in asp.
I can send the code, but maybe i can explain first what the problem is. At the top of the asp page i have inserted an iframe, with a special size. The ifarme links to menu.php.
So when users login, the menu will be shown in all my asp pages, for logged in users. But when they start to click on the menu, for example they want to go to the member_accountedit.php then that page will also appears inside the little iframe tag in the top of my asp page. And that is what i NOT want to do.
I want when they click on the menu, the member_acountedit.php will be shown in ANOTHER iframe, and the menu iframe is still at the top of the asp page.
I can send code if you need it :thumbsup:
Old Pedant
09-03-2010, 10:03 PM
Okay, that's easy.
But it would help *A LOT* if you would show the HTML for the top <iframe>. *NOT* the PHP code. Bring the page up in your browser and then RIGHT-CLICK within the <iframe> and get the HTML source for that iframe.
I will say that if you links are as simple as, say:
<a href="member_accountedit.php"> edit account </a>
Then all you have to do is add a target:
<a target="NAMEofOtherIframe" href="member_accountedit.php"> edit account </a>
and presto! The other iframe will show that url. Remember, it is the *NAME* of the iframe that you need.
Haidar
09-07-2010, 11:36 PM
Thats exactly how it's. But a stupid question. The page opens in a new window. I try to insert target="_parent" and target="_self" but it wont open in the same window.
:confused:
Old Pedant
09-08-2010, 12:09 AM
Show code. Show code. Show code.
Haidar
09-08-2010, 01:02 AM
Alright :D. Its a bit complicated, but the first code is written in all my asp pages, and its this one:
<iframe src="vipmenu.php" name="iframe" width="100%" marginwidth="0" height="100%" marginheight="0" scrolling="no" frameborder="0">
</iframe>
Then Vipmenu.php got this:
<?
/**
* UserEdit.php
*
* This page is for users to edit their account information
* such as their password, email address, etc. Their
* usernames can not be edited. When changing their
* password, they must first confirm their current password.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>
<html>
<?
/**
* User has submitted form without errors and user's
* account has been edited successfully.
*/
if(isset($_SESSION['useredit'])){
unset($_SESSION['useredit']);
echo "<h1>User Account Edit Success!</h1>";
echo "<p><b>$session->username</b>, your account has been successfully updated. "
."<a href=\"main.php\">Main</a>.</p>";
}
else{
?>
<?
/**
* If user is not logged in, then do not display anything.
* If user is logged in, then display the form to edit
* account information, with the current email address
* already in the field.
*/
if($session->logged_in){
?>
<a target="iframe_edit" href="settings.php" target="_parent"> edit account settings </a>
<?
}
}
?>
</body>
</html>
Then at least the settings.php got an iframe called "iframe_edit." Do you want the code for that page to?
Its a big complicated, but i have those steps because the first code will only show signed in user the menu.
Old Pedant
09-08-2010, 02:29 AM
NO NO NO! Don't want to see the PHP code. Want to see the HTML!
I told you in a prior message: Bring up the page in your browser and then right click in the <iframe> to find the HTML source code for that iframe. Post *THAT* code, not the PHP.
***************
Anyway, you say "the first code is written in all my asp pages". Okay, fine. So all your ASP pages have an <iframe> with the name "iframe".
But then you show that, in the code for "vipmenu.php" it tries to link to an iframe with the name "iframe_edit". But if you do that in an ASP page that does *NOT* have an an iframe with that name, then the link *WILL* open a new window. Period.
So where is "iframe_edit"????
Haidar
09-08-2010, 03:05 PM
The iframe_edit is only located at the asp page named vipedit.asp its another iframe in tje
Middle of the page.
Old Pedant
09-08-2010, 06:58 PM
Okay, so suppose you are on a page named "xyz.asp". And you are showing the <iframe name="iframe"> on that page. And the user clicks on the edit button.
WHAT do you want to have happen????
Do you want to load the page "vipedit.asp" to the main window and *then* load the <iframe name="iframe_edit">???
Yes, that's possible. A bit more work, but not impossible.
Haidar
09-09-2010, 01:38 AM
Hell Yeah!
Exactly what i want :thumbsup: and if its impossible, i cant wait untill i fix it!!
As you said. Im at page like xys.asp and there is an iframe called iframe_xys there. Then in that iframe when i click on a link i will reload the whole page and co to the new page called edit.asp and that page containt another iframe called iframe_edit :D
Old Pedant
09-09-2010, 02:10 AM
Okay, the easiest way to do this would be to change that edit link in the vipmenu.php page.
Change from:
<a target="iframe_edit" href="settings.php" > edit account settings </a>
To:
<a target="_top" href="vipedit.asp?frame=settings.php"> edit account settings </a>
And then change your "vipedit.asp" page from, where you are currently doing
<iframe name="iframe_edit" src="xxxx.php" [OTHER STUFF]></iframe>
, to:
<%
fsrc = Trim(Request("frame"))
If fsrc = "" Then fsrc = "xxxx.php" ' whatever file was the initial src of the iframe before
%>
<iframe name="iframe_edit" src="<%=fsrc%>" [OTHER STUFF]><iframe>
Presto.
See it? No matter what page you are on, even if you are on "vipedit.asp", clicking on that edit accounting setting link will force a load of "vipedit.asp" into the main page and *then* the code in "vipedit.asp" will find the frame= in the query string and use *THAT* for the src= of the <iframe>. Of course, if there isn't any frame= in the querystring, then "vipedit.asp" simply defaults to whatever would have been there anyway.
Dirt simple.
Haidar
09-10-2010, 12:50 AM
Iiiiiiiiiiiiiiiiiit worked :D
I swear you should win the nobel prize, thanks alot. The BEST pedant and smartest(clever) :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.