Jump to content

Recommended Posts

I am looking for advice if I am going about creating my web page in the correct way.

 

Here is my main index.php file.  Basically what I am trying to accomplish with this file is to provide the formatting for the whole site and a spot for all the content to come together.

 

<?php 

session_start();

include 'db/hhp_db.php';
include 'html_functions.php';
include 'login_functions.php';
include 'registration.php';
include 'gameinfo_display.php';
include 'laninfo_display.php';

html_header();
menu();
main_page();		
html_footer();

?>

 

This function pretty much drives the content of the site.  Except for the main.php which is just your standard hi welcome to the site info,  all the content is called by other functions from all those includes in index.php.  Basically this is what I came up with so I could call any function and still keep the site formatting going.

 

 function main_page(){
if ( $_GET['page'] == null ) {
	include("main.php");
}elseif	( $_GET['page'] == 'Home' ) {
	include("main.php");
}else{		
	$menu_link = $_GET['page'];
	$menu_link();
}

}

 

Here is the truncated version of the menu.  Basically shows 1 menu if your logged in and another menu if you not logged in.  Also a third menu for admins but like I said I shortened for space and I am just trying to give you an idea what I am doing.

 

function menu(){

if(isset($_SESSION['fld_user_id'])){
     ?>
          <ul>
                <li><a Href="?page=Home">Home</a></li>
                <li><a Href="?page=laninfo_display">Party Info</a></li>
                <li><a Href="?page=patch_display">Patches</a></li>
                <li><a Href="?page=driver_display">Drivers</a></li>
                <li><a Href="?page=logout">Logout</a></li>
          </ul>					
     <?php
}else{
     ?>
          <ul>
                <li><a Href="?page=Home">Home</a></li>
                <li><a Href="?page=login_form_display">Login</a></li>
                <li><a Href="?page=reg_email_form_display">                 Register</a></li>					
          </ul>
      <?php
}
    
}

 

Now here is my issue and why I think my system is flawed.   After login in order to get the page refresh with the correct menu I need to have the user hit a button to get it to work.

 

<H3>Login Successful!  Please enter site!</H3><br />
	<INPUT TYPE="BUTTON" VALUE="Enter" ONCLICK="window.location.href='?page=Home'">

 

I also have to do the same for log out.  Is there way to post ?page=home without pressing a button?  Is my way of going about this kinda hacky or am I on the right path and I just need to fine tune my code?  I would be interested in any thoughts or suggestions anyone with more experience than me would have.  Thanks in advanced!

With regard to your final question about changing the URL. Essentially you are talking about redirecting the user. You have a couple of options in that department. You could either go with php's header() or meta refresh

 

Header would be for immediate redirects, whereas meta refresh could work if you needed to display some sort of message to the user.

With regard to your final question about changing the URL. Essentially you are talking about redirecting the user. You have a couple of options in that department. You could either go with php's header() or meta refresh

 

Header would be for immediate redirects, whereas meta refresh could work if you needed to display some sort of message to the user.

 

I played around trying to use the header() but it would bark at me something about global variables every time I tried it. I will look into meta refresh to see if it is something I may want to use.

I think you're definitely on the right track.  I'm still lazy atm and haven't set it up this way yet.

 

For the $_GET['page'] I would create an array of possible values and do an if(in_array($_GET['page'], $array)) {

basically if you don't want someone to access a certain page.

For the $_GET['page'] I would create an array of possible values and do an if(in_array($_GET['page'], $array)) {

basically if you don't want someone to access a certain page.

 

LOL You kinda of read my mind.  This is something I been thinking about but haven't quite thought it all the way through yet.  I think it would be sweet when I add new content the site it gets added to a db.  Than the site is dynamically updated.  But I have a lot more tweaking to do before I get anywhere close to that.  I am trying to make a working site engine type of deal so I can use it for what ever kind of site I want.  This particular code I pulled from a site I use for a bunch of us guys who get together and LAN party all the time.  I also use a lot of those code for other little club type sites I that I do but I need to edit a lot of files for every site I use it with.  I have a few ideas for some commercial sites (? I dunno if that is the right term), I think I am a long way off till can tune my code till it runs like how I think a good site should run.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.