vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Actions for includes in php (https://vborg.vbsupport.ru/showthread.php?t=41632)

mr e 07-29-2002 04:33 AM

$action is something that PHP automatically does for you, when you do URL.php?action=WHATEVER...it doesn't have to be action either it could be URL.php?url=WHATEVER then you would just replace $action with $url, anyways this is what I do...

PHP Code:

print "<a href=\"index.php?action=forums\">Forums</a>"
print "<a href=\"index.php?action=news\">News</a>"

then do on index.php

if ($action == "forums") {
  
header ("Location: h ttp://www.URL.com/forum"//redirects you to the URL
} elseif ($action == "news") {
       include (
"news.php"//includes the page


take out the space between the h and the ttp: hopes this helps.

proxyMX 07-29-2002 12:49 PM

i used this to set the homepage as a default. However its not as efficent as id like. You see the problem im having is that i want to set the action of main
if ($action == "home") {
include ("http://www.proxymx.com/main.php");
as the loaded include when you load index.php
so i set it out like so

if ($action == "home") {
include ("http://www.proxymx.com/main.php");
} elseif ($action == "legal") {
include ("http://www.proxymx.com/legal.php");
}
else include ('http://www.proxymx.com/main.php');

However, this presents a problem, if a page isnt found on request, it simply directs the user back to the mainpage.

What i want to do is when a user enters the site {index.php} i want them to see the main.php page included. And then use actions such as ?action=forums for other pages
the code i used is sufficent to do so, however if ever a page is not found, it simply returns to the mainpage, when i want it to display the standard error pages if a page is not found.

So in short what i want to do is set the main.php as the default include when a user loads index.php, However if they type the wrong action i want the standard error messages to show up

mr e 07-29-2002 04:40 PM

Well you could try this

PHP Code:

if ($action == "home") {
include (
"http://www.proxymx.com/main.php");
} elseif (
$action == "legal") {
include (
"http://www.proxymx.com/legal.php");
} else{
include (
"404.html"); 

then you just upload the 404.html (or .htm i dunno) from you comp to the site and that's what will get displayed if the page isn't found. if you can't find the 404.html just type in a random URL and when the 404 error comes up just go File/Save As...

proxyMX 07-30-2002 10:08 PM

defeats the purpose :P

mr e 07-31-2002 03:46 AM

no it doesn't because it's saying if it doesn't find the page display an error, it just takes a little bit more work and it does exactly what u wanted it to do.

proxyMX 07-31-2002 06:14 PM

But then there would be no way to set the home as a deafult

mr e 07-31-2002 11:54 PM

Then try this

PHP Code:

if ($action == "home") {
include (
"http://www.proxymx.com/main.php");
} elseif (
$action == "") {
include (
"http://www.proxymx.com/main.php");
} elseif (
$action == "legal") {
include (
"http://www.proxymx.com/legal.php");
} else{
include (
"404.html"); 

there, i believe that solves your problem.


All times are GMT. The time now is 08:33 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03263 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete