Jump to content

[SOLVED] How to disable the values in address bar??


chanchelkumar

Recommended Posts

Hi Friends,

 

Am trying with a social network site... i want to disable the values in address bar which are passing as string variables, My pages are included in the index page.. and my values are passing like that... by changing the values in address bar my page is changing..

 

How can i solve this issue... i think anyone can change my site using this address bar.. how could i prevent this???

 

Help me...

Link to comment
Share on other sites

The problem of people changing the address bar is solved by checking the values they submit and verifying them.  There's no easy way around that.

 

If you want to avoid showing the values in the address bar then you can use post instead of get.  But that provides no additional security.  You must still verify the values.

Link to comment
Share on other sites

you could always cheat

 

rather than giving them all that in the address bar why dont you put a frame over the top of it ?!?

 

so that people go to

 

http://www.YOURSITE.com

 

and the frame inside loads the rest inside it ? that way people would not see the under links they could right click and copy link but in the code below is something to stop that ! unfortunatly if you get someone who really wants to get to your site its possible as with anything to do with computers try this

 

call this your index.html

 

<html>
<head>
<title>
YOUR SITE NAME
</title>

<script language="JavaScript">
<!--

var message="Sorry, that function is disabled.\nThis Page Copyrighted and\nImages and Text protected!\nALL RIGHTS RESERVED"; 

// Don't edit below!

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// --> 

</script>

</head>
<body>

<iframe width="100%" height="100%" frameborder=no src="<---Change To Your Site Address--->" 

allowTransparency="true">
</iframe>

</body>
</html>

 

give it a go ! should help you out :P

thanks

mike

 

p.s if this dont work let me know ill work something out

Link to comment
Share on other sites

I see your problem is 'solved', but I have to suggest you to use Apache's mod_rewrite, IF your server is an Apache of course.

 

When I code my sites I normally have my index.php serving all pages (like you), i.e. index.php?page=blog etc.  I then use mod_rewrite to 'hide' the file name and query string, thus having URLs like http://example.com/blog/. That's one of your problems solved. Read this article to get started with rewriting URLs: http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html.

 

Like people are suggesting, you should verify your query strings, only allowing the pages that actually outputs stuff. I use a simple array of allowed pages, and then check if the query string in question is part of that array, like this:

 

<?php
$page_array = array("blog", "and", "the", "rest", "of", "pages");
if (in_array($_GET['page'], $page_array)) {
	$page_exists = "TRUE";
} else {
	$page_exists = "FALSE";
}
?>

 

And then I output my 404 error message if $page_exists = "FALSE". You could also send users to another page if the query string is not in the array of allowed pages, and make sure that php stops executing code, like this:

 

<?php
$page_array = array("blog", "and", "the", "rest", "of", "pages");
if (!in_array($_GET['page'], $page_array)) {
	header("Location: URLTOPAGE");
	exit;
}
?>

 

Remember that headers have to be sent before anything else, so this code snippet needs to be in the very top of your index.php.

 

Hope I could help, or at least give you some ideas! :)

Link to comment
Share on other sites

You can simply verify if the page that user is in, is the same of the session on the user ex:

<?php
//...
if ($_GET['id'] != $_SESSION['id']) {
    die('You are trying to cheat you little bastard');

} 

//YOUR PROTECTED PAGE CODE HERE

//...
?>

 

I think it is the best and more secure way to pass data through GET URL without people cheat your code.

 

Link to comment
Share on other sites

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.