Ok, due to the nature of this question I've been unable to locate any answers that suit my needs over the past 2 days. I've searched google, php.net, and various other guide page web sites to no avail.
My question is regaurding php & navigation bars on web sites. A friend of mine had built a web site ages ago but I can't find the source code. The page had a navigation bar using only html, no javascript. It kept the same url without any extras (Such as ?variable=value), and was able to pass data to the page. The purpose for this was to use a single php file with multiple "Sections" and depending on the link that was selected a different "Section" would be echo'd on the body of the page.
I want to design a similar such instance, and like his old code I wanted to use regular html, no javascript and if I can help it no forms. I just want basic <a href=''> type tags that pass information along so when the page reloads it will bring up a different subject based on which link was selected.
I've come accross various scripts about forms & javascript submit functions, I don't mind using a form, but I do not want any javascript involved, it seems unnecissary. I am not sure if I'd add additional elements to the <a> tag such as name & value, or if I'd retreive those values with $_POST or another method. I know how to aquire information via $_POST and $_GET as well as use of sessions, but I am absolutely clueless as to how we did this before.
I don't mind using multiple php files or iframes, but for the purposes of expirmentation & efficiency I'd like to know the alternatives. There has to be a way to pass data without using the url to do so, having goofy id values in the url gets annoying to me.
Thanks in advance,
Casey D.
Navigation & PHP
Moderator: General Moderators
feyd | Please use
the body is:[/syntax]
As shown above.
Trouble is, how do I pass the selected link to the body when the page reloads. I don't want to use a $_GET method, where it would do for example: localhost/index.php?pageid=x, but rather just have it reload localhost and retreive the link as either a $_POST or non-visible selection.
I don't beleive the exact formatting is relative to be included, but if a change in formatting is necissary I'm open to suggestions. Also, I don't want to use javascript in this solution, I want it to be just with html and php, no client side scripts.
I'm not really concerned with security. I wasn't sure what additional parts I'd need to place into the <a> tags to allow the one selected to be found by the php script.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Sorry, I suppose I should have included an example.
I would have a div css designed frame, and use includes for the links header footer and body sections.
The url would just be the base url no extra sub section or directory, so on a test server simply "Localhost".
I want the links.php to include a set of links in a side-navigation bar such as:
// nav bar echo's
[syntax="html"]<b><p>Links:</b>
<a href='localhost'>page 1</a><br>
<a href='localhost'>page 2</a><br>
<a href='localhost'>page 3</a><br>
<a href='localhost'>page 4</a><br>the body is:[/syntax]
Code: Select all
<?php
$pageid = whatever value is passed from the selected link
switch ($pageid) {
case 1:
// echo's news
echo "Page 1";
break;
case 2:
// I think you get the idea
echo "Page 2";
break;
case 3:
case 4:
}As shown above.
Trouble is, how do I pass the selected link to the body when the page reloads. I don't want to use a $_GET method, where it would do for example: localhost/index.php?pageid=x, but rather just have it reload localhost and retreive the link as either a $_POST or non-visible selection.
I don't beleive the exact formatting is relative to be included, but if a change in formatting is necissary I'm open to suggestions. Also, I don't want to use javascript in this solution, I want it to be just with html and php, no client side scripts.
I'm not really concerned with security. I wasn't sure what additional parts I'd need to place into the <a> tags to allow the one selected to be found by the php script.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]You can use <a href="page_selector.php?page=1">page 1</a> and in page_selector.php use sessions and redirect to the main page.
and in your index.php
switch($_SESSION['page']) ...........
Code: Select all
session_start();
if(is_int($_GET['page'])) {
$_SESSION['page'] = $_GET['page'];
header('Location:index.php');
exit;
}
else die('Invalid page number.');switch($_SESSION['page']) ...........
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
I think you want "clean URLs" - they're "a good thing".
if you just want to hide the variables from the URL, you can use POST requests. But that would require a form for every link. You could probably get away with some javascript tomfoolery to submit a POST form instead of a link.
"clean URLs" is probably what you really want though, google that and you'll see what I mean
if you just want to hide the variables from the URL, you can use POST requests. But that would require a form for every link. You could probably get away with some javascript tomfoolery to submit a POST form instead of a link.
"clean URLs" is probably what you really want though, google that and you'll see what I mean
That's a rather brilliant idea, I wonder if that's how we did it before. I appreciate your advice on this, and I guess we can mark this as solved. When I can contact my friend about the site I'll check our method and post if there were any alternatives we used.
Thanks for the advice miro.
If anyone else has other ideas feel free to post them, I like having choices.
- Casey
Thanks for the advice miro.
If anyone else has other ideas feel free to post them, I like having choices.
- Casey