help in writting pages in modules

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
abolzouz
Forum Newbie
Posts: 13
Joined: Fri Mar 26, 2010 5:54 am

help in writting pages in modules

Post by abolzouz »

hi everyone...

im fairly new to web programming and more specifically to PHP.
what im trying to achieve is try to write different parts of my page separately and then glue them together, in this way my code will be more readable and easier to maintain.

my current situation is the following...i have a page named profile.php which im redirected to after login...
in this page i have a <div> for sidebar and another <div> for contents...
the side bar is a list of <a>
inside the <div> of the content; i catch the $_GET of the sidebar links and then glue another php file based on the $_GET parameter;
inside the newly glued php file i also have <a> tags but im not being able to catch them via $_GET...

here is part of my code.
the following is part of profile.php

Code: Select all

<div id="content">
                            <?php
                            if(isset ($_SESSION['userObject'])) {
                                $userObject = unserialize($_SESSION['userObject']);
                                if($userObject instanceof User) {
                                    if(isset ($_GET['action'])) {
                                        if($_GET['action'] == 'home') {
                                            require 'Objects/Service_Providers/Page_Parts/Control_Panel_Pages/HomeEntrySection.php';
                                        }?>
</div>
<div id="sidebar">
                        <ul>
                            <li>
                                <ul>
                                    <li><a href="profile.php?action=home">Home</a></li>
                                </ul>                                        
                            </li>
                        </ul>
                    </div>
now as you can see that when the user press the home link in the side bar, the HomeEntrySection.php in glued...
my problem is in the HomeEntrySection.php file..
here is how HomeEntrySection.php looks like:

Code: Select all

<?php
session_start();
if(isset ($_SESSION['userObject'])) {
    $userObject = unserialize($_SESSION['userObject']);
    if($userObject instanceof User) {
        if($userObject->isAdminUser()) {
            ?>
<h2 class="title">Administrator's Section</h2>
<div style="clear: both;">&nbsp;</div>
<div id="menu">
    <ul>
        <li><a class="current_page_item" href="menu=um">User Management</a></li>
    </ul>
</div>
my problem is that i cant catch the menu from $_GET...when i press the User Management it takes me to um...what i want is to be able to catch "um" in profile.php as a $_GET parameter....

thanks in advance
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: help in writting pages in modules

Post by minorDemocritus »

Code: Select all

<a class="current_page_item" href="page_that_gets_the_variable.php?menu=um">User Management</a>
Then it shows up in page_that_gets_the_variable.php:

Code: Select all

$test = $_GET['menu'];
echo $test;
When you click on the link, it should send you to page_that_gets_the_variable.php?menu=um, and display "um" without quotes.
Post Reply