• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
pintee

How to have index.php load different content

10 posts in this topic

Hi everyone,

 

I would like to have my website display different content while remaining on the same index.php page. The functionality I am after is demonstrated by www.sryth.com. If you sign up for an account, login, and start a new game, you will see what I mean. The address stays the same throughout the game(i.e. www.sryth.com/game/index.php), even as new content is being displayed. How do I achieve this effect??

0

Share this post


Link to post
Share on other sites
I was just working on this for a simple database for my work. I used the get method and sent a page name to my index page, and then have a switch statement to load each page the user will need to have access to using the include function. If you don't want the ?page= in your url, you can use the post method instead. Hope that helps some.
0

Share this post


Link to post
Share on other sites

[url="http://www.w3schools.com/xml/xml_http.asp"]http://www.w3schools.com/xml/xml_http.asp[/url]

 

you basically make a request to another php page in the background, and it responds with a plain-text response(exactly as if a user had accessed the page with their browser), you can attach post/get data and have the php on that page handle the input, and generate a response.  then use javascript to modify the user's page with this new data.

Edited by slicer4ever
0

Share this post


Link to post
Share on other sites

sorry michael, my php knowledge is rudimentary. I thought get and post methods were only if a form is involved. What if its just a page with links, and when you click on a link it remains as index.php but with different content? Thanks for your time.

0

Share this post


Link to post
Share on other sites
The get method doesn't require a new form. It just requires the data be correctly added to the url. I use links that look like www.mysite.com/index.php?page=home. I am also fairly crude with my php aswell though. I wanted this so I could use it to make the nav bar really simple.
0

Share this post


Link to post
Share on other sites

i think you can get away with

 

<?php include "someGenericButtons.html"; ?>
<?php
var $navigationBarToShow = GET['nav']; //Get Navigation from header (So 'TOPLEVEL' or something)
 
if($navigationBarToShow == 'TOPLEVEL')
    include "Navigation/ToplevelNavigation.html";
?>

 

then, in your navigation bar, your buttons simply point at

 

<a href="index.php?Nav=Button1">Button 1</a>

 

or Similar, My web knowledge isn't great, but this is how i did my 2nd Year Uni Web Project.

 

EDIT: Note this is Semi-psudo code :P

Edited by Andy474
1

Share this post


Link to post
Share on other sites
I've been experimenting with www.sryth.com in order to glean how it might be reverse-engineered.

* Firstly I login and start off from www.sryth.com/game/index.php. (this has content on it like text and links)

* Secondly, I open a link on the page in a new window. This brings up the address http://www.sryth.com...ioussectionid=1

for a split second before redirecting to the address http://www.sryth.com...f_c=parser2.inc (this page also has content on it like text and links).

Any guesses as to the implementation from what I have just described?
0

Share this post


Link to post
Share on other sites

To add to Andy474... You can do the same with .php files if you want he content to be dynamic from a database. I just add modrewrite to my htaccess file and it is no problem.

 

So instead of going to www.example.com/index.php?somepage=blah&somethingelse=something

 

using modrewrite you can handle links to be like,

 

www.example.com/blah/something to clean it up...

 

have the index.php file handle the $_GET[somepage] and $_GET[somethingelse]

 

then as Andy474 stated do include "blah/something.php"

 

You can of course change that however you like and allow for a lot more parameters if you need to. Hope this helps a little.

0

Share this post


Link to post
Share on other sites

eek.. I think what you want to look into is a combination of jQuery and ajax.   jQuery has all the capabilities on the browser end you need, including a way to update the history and append hashbangs to urls so users can still use the back button with their browser.   Instead of an xmlhttprequest call directly you're better off using a mature library like jquery.

 

Maybe start with looking at something like this:  http://iviewsource.com/codingtutorials/learning-how-to-use-jquery-ajax-with-php-video-tutorial/

 

An ajax example on our site is when you click "Top Members" and start typing a username.. no page reloads to generate the content on the members page.

Edited by Michael Tanczos
2

Share this post


Link to post
Share on other sites

Indeed, sorry I couldnt give decent example code, I was on a phone. Andy's method is what I was refering to.

 

My index page loading looks like

 

if     ($Page == 'home')        {include('MainPage.html');}
else if($Page == 'login')       {include('LoginPage.html');}
else if($Page == 'loginsuccess'){include('LoginSuccess.php');}
else if($Page == 'logout')      {include('Logout.php');}
else                             {include('MainPage.html');}
 

for displaying the different pages, and <li><a href=\"Index.php?Page=login\">Login</a></li> for the different navagation bars. This is a really poor example and could be inproved on a lot, but Eh maybe you will find it more userful then just saying steps, my syntax is ugly as hell but I tend not to worry about my syntax rules until my 2nd or 3rd rewrite for sometime when its less "lets try and get this to work right" and more "lets try and make this modifyable, work right, and easy to read"

 

<?php
session_start();

echo "<div id=\"navbar\">
<ul>

<li><a href=\"Index.php?Page=home\">Home</a></li>";

if($_SESSION['myusername']==''){echo

"<li><a href=\"Index.php?Page=signup\">Signup</a></li>
<li><a href=\"Index.php?Page=login\">Login</a></li>";}

else{echo
"<li><a href=\"Index.php?Page=logout\">Logout</a></li>";}

echo"
</ul>
</div>
<div id=\"main\">";


echo $_SESSION['myusername'];
echo "<br>";
$Page = $_GET['Page'];

if     ($Page == 'home')        {include('MainPage.html');}

else if($Page == 'login')       {include('LoginPage.html');}
else if($Page == 'loginsuccess'){include('LoginSuccess.php');}
else if($Page == 'logout')      {include('Logout.php');}

else                             {include('MainPage.html');}



echo"</div>";



?>
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0