Brian77 Posted August 8, 2006 Share Posted August 8, 2006 I really don't know where to ask this question, I even tried over at where they make this game and they never answered...so here it goes.I play an RPG game on my fourm. There is 4 directions one may travel on the main zone.php page. Upon clicking where they want to go, they are taken to a page that tells them that it was successful and click here to return to the previous page. I would like them to only click ONCE the direction they want to go, and basically refreshing the zone.php file, and being in the new area they chose. How can I accomplish this? It would save clicking, and it would also save me bandwidth because that whole page isn't coming up anymore. This is at the end of one direction that is in my zone.php page.//Update character zone $sql = " UPDATE " . RPG_CHARACTERS_TABLE . " SET character_area = '$destination_id' WHERE character_id = '$user_id' "; if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not update character zone', '', __LINE__, __FILE__, $sql); rpg_previous( Rpg_zone_change_success , rpg_zones , '' ); break;I have already tried removing the rpg_previous( Rpg_zone_change_success , rpg_zones , '' ); line of text from all points, and it worked, but it didn't refresh the page. Ex: I was in Area 1, clicked North to Area 2, and it brought back my zone.php page....but I was STILL in Area 1, but according to my DB, I really was in Area 2, and hitting F5 would change it. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 8, 2006 Share Posted August 8, 2006 So when a user click on a link, it sends them to a new location. So is the page refreshed with the locations new attributes? Or are they being forwared to a new page each time and you want to just make it reload the current page with the new location within it?You can redirect them to the same page with header()so[code]<?php$movetoID = 453; // SQL id for the location they wish to move toheader("Location: {$_SERVER['PHP_SELF']}/location.php?locid={$movetoID}");exit();?>[/code]Though you can see people could just input their own room locations into the URL which is umm a bit of a cheat. I guess you would do some sort of POST, which would at least stop them from entering where ever they want to go. Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 8, 2006 Share Posted August 8, 2006 Do a header relocation:[code=php:0]//Update character zone$sql = "UPDATE " . RPG_CHARACTERS_TABLE . " SET character_area = '$destination_id' WHERE character_id = '$user_id' ";if( !($result = $db->sql_query($sql)) ){ // Zoning failed $zoned = false;} else { $zoned = true;}// go back to zone pageHeader("Location: zone.php?zoned=".$zoned);// Stop further page executionexit;[/code]and on your zone.php, where you show the current zone info:[code=php:0]if($_GET['zoned'] == true){ // Zone was successful} else { // Zoning failed}[/code] Quote Link to comment Share on other sites More sharing options...
Brian77 Posted August 8, 2006 Author Share Posted August 8, 2006 Adding that to the zone.php file works, slightly, but it doesn't actually refresh the page to the new area without pressing F5 or refresh. Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 8, 2006 Share Posted August 8, 2006 That sounds like a caching problem. Try this:[code=php:0]<?phpheader("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past?> [/code]More information on cache control can be found here:http://us2.php.net/manual/en/function.header.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.