Jump to content

Help with PHP security


barefootsanders

Recommended Posts

Hey everyone.  I have been developing a 2d browser based game with PHP and MySQL. It is not finished yet but it is close.  I was hoping someone experienced in PHP could help me make it as secure as possible.  I am good with PHP however I don't have very good knowledge with PHP security.  If anyone is willing to help please shoot me an email at solidgold10287@aol.com.  Thanks!

Link to comment
Share on other sites

Well I read somewhere that the command $_GET was not all that secure along with include() statements.  This my center <div> which loads the correct page based on what someone clicked.  The links are set up like this:

 

<li><a href="index.php?page=userinfo&id=<?php echo $session->userid;?>">My Account</a></li>

 

And heres the code:

<?php

$page = $_GET['page'];

switch ($page)
{
case register: //Register was clicked
	include("register.php");
	break;
case welcome: //The main home page
	include("welcome.php");
	break;
case userinfo: //User info page
	include("userinfo.php");
	break;
case useredit: //User edit page
	include("useredit.php");
	break;
case levelup:
	include("levelup.php");
	break;
case attack: //Attack page
	include("attack.php");
	break;
case admincenter: //Admin center - FOR ADMINS ONLY!
	include("admin/admin.php");
	break;
case newfamily: //Create a new family page
	include("newfamily.php");
	break;
case familyinfo:
	include("familyinfo.php");
	break;
case familyinvite:
	include("familyinvites.php");
	break;
case editfamily:
	include("editfamily.php");
	break;
case travel:
	include("travel.php");
	break;
case viewmap:
	include("viewmap.php");
	break;
case forgotpass: //Forgot password was clicked
	include("forgotpass.php");
	break;
default:
	include("welcome.php");
}
?>

 

 

Link to comment
Share on other sites

<li><a href="index.php?page=<?php echo base64_encode('userinfo');?>&id=<?php echo base64_encode($session->userid);?>">My Account</a></li>

Use base64_decode() To Decode the encoded String.

switch (base64_decode($page))

 

I see where this could help however I wanted each user to have a unique ID that could be used to access ones profile.  So say one wanted to view another profile I wanted to just have the user click on their profile which would give the user their own profile and then they could just change the number to the certain ID they wanted to view.  Is this not a secure way to do things??

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.