Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Include Files Problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Include Files Problem

 Post Reply Post Reply Page  12>
Author
Diddl View Drop Down
Newbie
Newbie
Avatar

Joined: 11 September 2003
Location: Denmark
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diddl Quote  Post ReplyReply Direct Link To This Post Topic: Include Files Problem
    Posted: 19 September 2003 at 1:52pm

Hi

I have a little problem - i'm trying to get my website up around a page called at the moment index.asp

On the page is a table that i want to have information from other files on the site - how do i do that?

example:

Http://disney.adsl.dk/index.asp?page=main

should show the mainpage information. and:

page=anmeldelser

should show a page located in /html/anmeldelser.asp

How do i get that to work in a simple way. - i could write a lot of "if lines" but i would rather have a more simple solution if that is possible.

And if there is a easy DB solution to the problem i'm listing to that to.

Kind Regards
Charlie Jensen

Back to Top
3BEPb View Drop Down
Groupie
Groupie


Joined: 07 August 2003
Location: United States
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote 3BEPb Quote  Post ReplyReply Direct Link To This Post Posted: 20 September 2003 at 12:35am

sinse you are working on ASP - write the following line:

<%

response.redirect "html/" & Request("page") & ".asp"

%>

But make sure html is not the name of your root folder, you can see in your FTP, once after logging in to your site :)

If it is the name of root - just delete the following part of the code above:

"html/" &

Back to Top
Diddl View Drop Down
Newbie
Newbie
Avatar

Joined: 11 September 2003
Location: Denmark
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diddl Quote  Post ReplyReply Direct Link To This Post Posted: 20 September 2003 at 12:41am

Hi

Thanx for the answer. But isn't there anyway i can open the page within the page - just so i don't have to include headers and footers and menu's in all the pages.

But if that's not possible i'll just use the abouve metode.

Kind regards
Charlie Jensen

Back to Top
FLATLINE View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2002
Location: Israel
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote FLATLINE Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2003 at 11:42am

You can try and use a recordset that opens a table from a DB.
The DB table will have at least two columns: One will be the exact name of the page in the html/ folder, and the other will have the reference name which will be used in the ?page= querystring.

This way you can query the name of the page you want to include from the database in accordance to the query:

<%
Dim strPage  ' The querystring ?page= for the page reference name
Dim strPageInclude  ' The exact name of the page to include

strPage = Request("page")
If strPage = "" Then  'If not page reference name provided
strPageInclude = "main.asp"  'Skip the DB search, and set for the main page
Else  ' If a page was given, begin the DB search

strSQL = "SELECT * FROM pages WHERE page_ref = '" & strPage & "';"
Set rsPage = Server.Createobject("adodb.recordset")
rsPage.open strSQL, ado
If rsPage.EOF Then  ' If no page with that reference name was found
strPageInclude = "error404.asp"  ' Include a 404 not found error page
Else
strPageInclude = rsPage("page_name") ' Otherwise, draw the page name from the DB
End If
rsPage.Close
Set rsPage = Nothing

End If

Response.Write("#include file='html/" & strPageInclude & "'"
%>

I hope my advice helped you



Edited by FLATLINE
Visit my site: DarkGreen HQ
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2003 at 11:07am
is there any way to solve this out without database?
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2003 at 12:04pm

Use an array at the top of the asp page instead of a database:

Dim array(num_pages), page
array(0) = "page1.asp"
array(1) = "page2.asp"

for each page in array
  if request.querrystring("page") = left(page, len(page) - 4) Then
    server.execute(page)
  else
    server.execute("errorpage.asp")
  end if
next

- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2003 at 1:44pm
<%
Dim page
page = request.querystring("page")
page = "html/" & page
server.execute page
%>
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2003 at 2:02pm

okay, but then, why not just use

<%
dim page
page = Request.QueryString("page")
%>

and

<% Server.Execute"" & page & "" %>

??

thanks for ya help but when using server.execute the page i include wont load other variables. like, i have several skins with different images on my page and the page loads the skin from another querystring but the included page wont load the variables so then it wont load the images neither. so is there any other ways to do this? without server.execute?

sorry my bad english.. if it is bad..

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.