Edit: Fixed
This is some thing that I've been thinking about for quite a while now and I'm really lost as to how to do it.
I'm creating a game where each npc has and id, at the moment when a player clicks on a link for example
http://vizuke.com/ready.php?npcid=1 the npc id is stored in a variable in the url as you can see and that's how I'm able to tell the browser what the opponent of my character will be.
I've been thinking of ways to send the npcid without people being able to tamper with it, I don't really care if they see the Id or not what I care about is not let them choose the npc they want.
I've tried to find ways to do this by, for example sending the id to the database before hand and then the database would check If the player is against the right character or well could just get the id from the database but the problem is I can't make it send the number on the click of a link.
I have though of using a button and then in php I could put the variable that it's supposed to send but I've been having some problems there because I included a php page by first of all adding
<script type="text/javascript" src="map data/mapbattle.js" ></script>
<div id='mapbattle'></div>
to the main source and the the mapbattle.js code is:
function getbattle() {
var xmlHttpGalsamp=null;
try {
xmlHttpGalsamp = new XMLHttpRequest();
} catch (e) {
try {
xmlHttpGalsamp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttpGalsamp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlHttpGalsamp.onreadystatechange = function() {
if (xmlHttpGalsamp.readyState == 4)
try {
if (xmlHttpGalsamp.status == 200) {
document.getElementById("mapbattle").innerHTML
= xmlHttpGalsamp.responseText;
}
} catch (e) {
document.getElementById("mapbattle").innerHTML
= "Error on Ajax return call : " + e.description;
}
}
xmlHttpGalsamp.open("get","map data/mapbattle.php");
xmlHttpGalsamp.send(null);
}
I really can't load the thing when I click on the button(which is in mapbattle.php) because when I click on the button nothing happened and that's because the getbattle() function only gets the inner html and puts it in the div and so it can't take php with it specially since it's server side, btw I know it's possible with a frame but don't want to use one.
And so I'm either searching for a solution on how to protect the npcid or a way to fix the button.Sorry if I couldn't really explain correctly, if you didn't understand what I meant please feel free to ask again.
I would really appreciate your help, thank you.
Sorry, I'll try to recreate the button thing to see what my problem was...
Edit:Never mind I fixed it. Instead of doing all this crap all I could have used was the jquery .load() ...