FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need help with a HTML / PHP question.





XeononyX
I was wondering if anyone knew how to make a web page load a certain way depending on what they type in the address bar:

For example if someone types in the address bar : http://xeononyx.frihost.net it directs you to my page with the default index page (my forum)

But I was wondering if there was a way I could make a link like so :
http://xeononyx.frihost.net/index.htm?loc=downloads
so it will load up my index page and put the index of the dowloads folder in the inline frame instead of the default index of the forum.

I would like to go as far to even be able to type in:
http://xeononyx.frihost.net/index.htm?forum/viewforum.php?f=4
so it will load up a specific post in my forum and put the inline frame around it.

Is this possible or am I climbing the wrong tree?
TomS
You'll need php. Maybe Javascrpit works, too. but I don't really know.

eg. "http://http://xeononyx.frihost.net/index.php?loc=downloads"

Code:
<?php
if ($_GET["loc"]=="doanloads")
{
#View Downloadsite
}
?>


^^This is not a working code. Just kind of a template.
LukeakaDanish
Its entirely possible, but you need to use something more than HTML - my suggestion would be PHP

Firstly: save all your index.htm file as index.php

then add the following code wherever you want the value of "loc" from the address (in this case inside the "href" value of your iframe):

Code:

<?php

//load post variables (security is not needed as file is not included):
$loc = $_POST['loc'];

//print the location
echo $loc;
?>


HOWEVER: There's a better way to do it. With php you can include the content of your other documents without using iframes (google cant read whats inside iframes, and they increase load times). This way you would probably place the content of your external document in a <div> container, and then strip the <html>,<head> and <body> tags from the document you wish to add to your page.

- all you have to do is exchange "echo" with "include" in the code above. There is a security issue with this though, if you have any pages you dont want your visitors to see - otherwise you should be ok though (if you want to know about the security stuff, search for "php htmlspecialchars" on google.)
XeononyX
Excellent! Thank you I was pretty sure php was involved, thanks for point me in the right direction.
XeononyX
This is the code for my index:
Code:
<html>

<head>
<link rel="icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>XeononyX OnLine</title>
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: 12px Arial Black; color: red; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>

<script language="JavaScript">

//Top Nav Bar I v2.1- By Constantin Kuznetsov Jr.
//Modified by Dynamic Drive for various improvements
//Visit http://www.dynamicdrive.com for this script

var keepstatic=0 //specify whether menu should stay static (works only in IE4+)
var menucolor="#000000" //specify menu color
var submenuwidth=150 //specify sub menus' width

</script>
</head>

<body link="#FF0000" vlink="#FF0000" alink="#FF0000" text="#FFFFFF" bgcolor="#000000" style="text-align: center">
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menucontext.js"></script>
<script language="JavaScript">
showToolbar();
</script>
<script language="JavaScript">
function UpdateIt(){
if (ie&&keepstatic&&!opr6)
document.all["MainTable"].style.top = document.body.scrollTop;
setTimeout("UpdateIt()", 200);
}
UpdateIt();
</script>
<p>
<font size="1" color="#FFFFFF">


<br>
<iframe name="I1" src="forum/index.php" align="center" width="100%" height="89%" marginwidth="01" marginheight="01">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe></font>

<a target="I1" href="Online.htm">
<img border="0" src="XeononyXonline.gif" width="500" height="50"></a></p>

</body>

</html>


Where would you put the php code? before everything ? in the head ? thanks again any help would be appreciated !
I usually don't ask for this much help but this is making me stumped.
TomS
Look for the comment in the source code:

Code:
<html>

<head>
<link rel="icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>XeononyX OnLine</title>
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: 12px Arial Black; color: red; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>

<script language="JavaScript">

//Top Nav Bar I v2.1- By Constantin Kuznetsov Jr.
//Modified by Dynamic Drive for various improvements
//Visit http://www.dynamicdrive.com for this script

var keepstatic=0 //specify whether menu should stay static (works only in IE4+)
var menucolor="#000000" //specify menu color
var submenuwidth=150 //specify sub menus' width

</script>
</head>

<body link="#FF0000" vlink="#FF0000" alink="#FF0000" text="#FFFFFF" bgcolor="#000000" style="text-align: center">
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menucontext.js"></script>
<script language="JavaScript">
showToolbar();
</script>
<script language="JavaScript">
function UpdateIt(){
if (ie&&keepstatic&&!opr6)
document.all["MainTable"].style.top = document.body.scrollTop;
setTimeout("UpdateIt()", 200);
}
UpdateIt();
</script>
<p>
<font size="1" color="#FFFFFF">
<br>

<!-- LOOK. HERE IS THE PHP-CODE -->


<iframe name="I1" src="<? echo $_GET["loc"]; ?>" align="center" width="100%" height="89%" marginwidth="01" marginheight="01">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe></font>

<a target="I1" href="Online.htm">
<img border="0" src="XeononyXonline.gif" width="500" height="50"></a></p>

</body>

</html>



The file have to be saved as "index.php"

Then you can type something like this in your adress bar:

http://XeononyX.frih.net/index.php?loc=site1.htm
or
http://XeononyX.frih.net/?loc=site1.htm

Then "site1.htm" will appear in the iframe...
LukeakaDanish wrote:
<?php

//load post variables (security is not needed as file is not included):
$loc = $_POST['loc'];

//print the location
echo $loc;
?>


Sorry. This won't work. Because you used $_POST["loc"].
Then you need a form, that submits the site or somthing like that...
XeononyX
hey that works great .. now I assume I'll have to make some form of php code with an if then statement to determine if we're going to the default or not .. correct?

The index Im' workin on is moved to a different folder until I get it working.

http://xeononyx.frihost.net/cards -- this is without a loc I would like it goto http://xeononyx.frihost.net/forum/index.php if a user doesn't specify a loc.

http://xeononyx.frihost.net/cards?loc=http://www.myspace.com/xeononyx -- this works perfect.

Wohoo.. it works : i did a little searching and trial and error and added the code:

Code:
<?php
$Warp = $_GET['loc'];
if (!$Warp) {
$Warp = "http://xeononyx.frihost.net/forum/index.php";
}
?>


at the beginning and in the frame I put:

Code:
<iframe name="I1" src="<? echo $Warp; ?>" align="center" width="100%" height="89%" marginwidth="01" marginheight="01">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
LukeakaDanish
XeononyX wrote:
hey that works great .. now I assume I'll have to make some form of php code with an if then statement to determine if we're going to the default or not .. correct?

The index Im' workin on is moved to a different folder until I get it working.

http://xeononyx.frihost.net/cards -- this is without a loc I would like it goto http://xeononyx.frihost.net/forum/index.php if a user doesn't specify a loc.

http://xeononyx.frihost.net/cards?loc=http://www.myspace.com/xeononyx -- this works perfect.


Yea...sorry about forgetting that...here's the updated code:

Code:

<?php
if ($_GET['loc']) {
echo $_GET['loc'];
}
else {
header("Location: http://xeononyx.frihost.net/forum/index.php");
}
?>



ok?
TomS
>>hey that works great .. now I assume I'll have to make some form of php code with an if then statement to determine if we're going to the default or not .. correct?


Jup. right.
Again, look for the "<!-- comment -->"....

Code:

<html>

<head>
<link rel="icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://xeononyx.frihost.net/favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>XeononyX OnLine</title>
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: 12px Arial Black; color: red; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>

<script language="JavaScript">

//Top Nav Bar I v2.1- By Constantin Kuznetsov Jr.
//Modified by Dynamic Drive for various improvements
//Visit http://www.dynamicdrive.com for this script

var keepstatic=0 //specify whether menu should stay static (works only in IE4+)
var menucolor="#000000" //specify menu color
var submenuwidth=150 //specify sub menus' width

</script>
</head>

<body link="#FF0000" vlink="#FF0000" alink="#FF0000" text="#FFFFFF" bgcolor="#000000" style="text-align: center">
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menucontext.js"></script>
<script language="JavaScript">
showToolbar();
</script>
<script language="JavaScript">
function UpdateIt(){
if (ie&&keepstatic&&!opr6)
document.all["MainTable"].style.top = document.body.scrollTop;
setTimeout("UpdateIt()", 200);
}
UpdateIt();
</script>
<p>
<font size="1" color="#FFFFFF">
<br>

<!-- LOOK. HERE IS THE PHP-CODE -->
<?php
if (!isset($_GET["loc"]))
{ $location = "forums/index.php"; }
else
{ $location = $_GET["loc"]; }
?>

<iframe name="I1" src="<? echo $location; ?>"
 align="center" width="100%" height="89%" marginwidth="01" marginheight="01">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe></font>

<a target="I1" href="Online.htm">
<img border="0" src="XeononyXonline.gif" width="500" height="50"></a></p>

</body>

</html>
XeononyX
Sorry .. late respones:

Wohoo.. it works : i did a little searching and trial and error and added the code:

Code:
<?php
$Warp = $_GET['loc'];
if (!$Warp) {
$Warp = "http://xeononyx.frihost.net/forum/index.php";
}
?>


at the beginning and in the frame I put:

Code:
<iframe name="I1" src="<? echo $Warp; ?>" align="center" width="100%" height="89%" marginwidth="01" marginheight="01">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>


This was great brainstorming guys ... please lemme get your guys' addys you want me to put in the source comments for your help Smile
Related topics
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.