Need Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wolfwood16
Forum Commoner
Posts: 43
Joined: Wed Aug 27, 2008 8:52 am
Contact:

Need Help

Post by wolfwood16 »

Hi there and Good day to all,

I'm currently working a project. It's a custom made CMS for my website project. Currently i'm experiencing a hard time solving my problem since i'm a beginner. And so, help from you guys will be great smile for me :D

Anyway here's my problem, i've noticed that some CMS consider user's actions as "mode" plus the action itself (ie. http://localhost/site/index.php?mode=action). On the site i've made there's a loginpage that will redirect to a page with a Default mode named adm_editpage.php?mode=Default. there's a bunch of code i've made inside the adm_editpage.php:

Code: Select all

<div class="div_main_cont_">
                [color=#FF0000]<?php[/color]
                [color=#0000FF]switch[/color] ($_GET["[color=#008000]mode[/color]"]) {
                   [color=#0000FF] case[/color] [color=#008000]"GoNews"[/color]:
                        printContentDiv_GoNews();
                        [color=#0000FF]break[/color];
                    [color=#0000FF]case[/color] [color=#008000]"GoActSched"[/color]:
                        [color=#0000FF]echo[/color] $printContentDiv_GoActSched;
                        [color=#0000FF]break[/color];
                    [color=#0000FF]case[/color] [color=#008000]"GoSchoolStory"[/color]:
                        printContentDiv_GoSchoolStory();
                        [color=#0000FF]break[/color];
                    [color=#008000]case[/color] [color=#008000]"GoAlumni"[/color]:
                        [color=#0000FF]echo[/color] $printContentDiv_GoAlumni;
                        [color=#0000FF]break;[/color]
                    [color=#0000FF]case[/color] [color=#008000]"Default"[/color]:
                        printContentDiv_QuickPost();                             
                        [color=#0000FF]break;[/color]
                }
                
           [color=#FF0000]     ?>[/color]
               
             </div>
This will return the printContentDiv_QuickPost() since the url was set to adm_editpage.php?mode=Default.

Here's the code of printContentDiv_QuickPost():

Code: Select all

 
[color=#0000FF]if[/color] ([color=#400000]$_REQUEST[/color][[color=#008000]'mode'[/color]] == [color=#008000]"Default"[/color]) {
 
    [color=#0000FF]switch[/color] ([color=#400000]$_GET[/color][[color=#008000]'quickmgtMode'[/color]]) {
        [color=#0000FF]case[/color] [color=#008000]"isAddingNews"[/color]:
                   [color=#0000FF]print[/color] [color=#00BFFF]<<<HERE[/color]
                    hello world you are adding news
[color=#00BFFF]HERE;[/color]
        [color=#0000FF]break;[/color]
 
[color=#0000FF]    default:[/color]
 
        [color=#400000]$qlink_article[/color] = [color=#400000]$_SERVER[/color][[color=#008000]'PHP_SELF'[/color]].[color=#008000]"?quickmgtMode=isAddingNews"[/color];
        [color=#400000]$qlink_event[/color] = [color=#400000]$_SERVER[/color][[color=#008000]'PHP_SELF'[/color]].[color=#008000]"?quickmgtMode=isAddingEvent"[/color];
        [color=#400000]$qlink_usrmgt[/color] = [color=#400000]$_SERVER[/color][[color=#008000]'PHP_SELF'[/color]].[color=#008000]"?quickmgtMode=isUsrMgt"[/color];
        [color=#0000FF]print[/color] [color=#00BFFF]<<<HERE[/color]
               <a href="$qlink_article" id="font_quick_management">News</a> 
               <a href="$qlink_event" id="font_quick_management">Event Schedule </a>
               <a href="$qlink_usrmgt" id="font_quick_management">Quick User Management </a>
                      
                hello world this is the default!
 
[color=#00BFFF]HERE;[/color]
[color=#0000FF]        break;[/color]
    }
}
It printed the div contents as it was set to Default. But the quickmgtMode=isAddingNews parameter isn't working and not printing the "hello world you are adding news"...

What are my mistakes? helps and replies will be much appreciated! thank you so much in advance!
wolfwood16
Forum Commoner
Posts: 43
Joined: Wed Aug 27, 2008 8:52 am
Contact:

Re: Need Help

Post by wolfwood16 »

up and edited :)
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Need Help

Post by jayshields »

It's because $_GET['mode'] and $_REQUEST['mode'] are the same things. So if $_GET['mode'] is equal to "Default" then $_REQUEST['mode'] will be "Default".
wolfwood16
Forum Commoner
Posts: 43
Joined: Wed Aug 27, 2008 8:52 am
Contact:

Re: Need Help

Post by wolfwood16 »

jayshields wrote:It's because $_GET['mode'] and $_REQUEST['mode'] are the same things. So if $_GET['mode'] is equal to "Default" then $_REQUEST['mode'] will be "Default".
yes it's doing the same thing, the $_REQUEST['mode'] == "Default" in the printContentDiv_QuickPost() will just recheck if the mode is really set to "Default" from the adm_editpage.php .

but since value to get is just the same (mode=Default), the printContentDiv_QuickPost() is not printing the "hello world you are adding news" when the users click the $qlink_article.

to be exact, the printContentDiv_QuickPost() is just returning its default switch value even if we set the quickmgtMode to isAddingNews .....
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Need Help

Post by jayshields »

Sorry I misunderstood, your code is very confusing and it looks like you've syntax highlighted it yourself...

I think you need to edit these lines:

Code: Select all

$qlink_article = $_SERVER['PHP_SELF']."?quickmgtMode=isAddingNews";
$qlink_event = $_SERVER['PHP_SELF']."?quickmgtMode=isAddingEvent";
$qlink_usrmgt = $_SERVER['PHP_SELF']."?quickmgtMode=isUsrMgt";
and change them to:

Code: Select all

$qlink_article = $_SERVER['PHP_SELF']."?mode=Default&quickmgtMode=isAddingNews";
$qlink_event = $_SERVER['PHP_SELF']."?mode=Default&quickmgtMode=isAddingEvent";
$qlink_usrmgt = $_SERVER['PHP_SELF']."?mode=Default&quickmgtMode=isUsrMgt";
 
wolfwood16
Forum Commoner
Posts: 43
Joined: Wed Aug 27, 2008 8:52 am
Contact:

Re: Need Help

Post by wolfwood16 »

Thanks jayshields, it solved my problem :)

hmmm just a bit of question,how do we call this stuffs? and is it possible to extend additional conditional linking? like

Code: Select all

[color=#400000]$_SERVER[/color][[color=#008000]'PHP_SELF'[/color]].[color=#008000]"?mode=Default&quickmgtMode=isAddingNews&doingMore=yes&evenMore=yes"[/color];
is this possible?
Post Reply