How to hide URL params?

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

User avatar
shoebappa
Forum Contributor
Posts: 158
Joined: Mon Jul 11, 2005 9:14 pm
Location: Norfolk, VA

Post by shoebappa »

Caught me bored... Proof of concept:

http://www.odu.edu/test/php/hideurl.php

Code: Select all

<?php

	session_start();

	if (count($_GET) > 0) {
		$_SESSION["GET"] = serialize($_GET);
		header("Location: hideurl.php");
		exit();		
	}

	if (count($_POST) > 0) {
		$_SESSION["POST"] = serialize($_POST);
		header("Location: hideurl.php");
		exit();		
	}

	echo "GET: " . count($_GET) . "<br>";
	echo "POST: " . count($_POST) . "<br>";
	
	if (isset($_SESSION["GET"])) {
		$_GET = unserialize($_SESSION["GET"]);
	}

	if (isset($_SESSION["POST"])) {
		$_POST = unserialize($_SESSION["POST"]);
	}
	
	session_destroy();

?>

<html>
<body>
<h1><pre>GET: <?php print_r($_GET); ?></pre></h1>
<h1><pre>POST: <?php print_r($_POST); ?></pre></h1>
<a href="hideurl.php?link=link1">Link 1</a> | <a href="hideurl.php?link=link2">Link 2</a> | <a href="hideurl.php?link=link3">Link 3</a><br>
<form method="post"><input type="submit" name="link" value="link1"><form method="post"><input type="submit" name="link" value="link2"><form method="post"><input type="submit" name="link" value="link3">
</body>
</html>
Naturally back is hosed although not as annoying, just as if you didn't load a new page, kinda interesting... Prolly not ideal, but that's what I got.
Post Reply