Ik heb een error bij mij php/javascript en dat is best wel irritant, ik ben bezig met een account edit/bekijken systeem te maken
hier is mijn code:
ik heb de mysql data ff wegehaald voor eeuuh, je weet wel tegen het stelen van data, maar oke ik heb dus een error met "id word verwacht" bij het laden van de pagina en ik krijg "object word verwacht waneer ik op save klik"
hier is mijn code:
PHP:
<?php
if(isset($_POST['pass']))
{
if($_POST['pass'] == "screwyou")
{
if($_POST['logged'] == "true")
{
phpinfo();
}
function GetWeaponName($id)
{
switch($id)
{
case 0: return "None";
case 22: return "9 mm";
case 23: return "Silenced 9mm";
case 24: return "Desert Eagle";
}
}
function GetWeaponName2($id)
{
switch($id)
{
case 0: return "None";
case 29: return "SMG";
case 28: return "Micro SMG";
case 32: return "Tec9";
}
}
function GetWeaponName3($id)
{
switch($id)
{
case 0: return "None";
case 23: return "Silenced 9mm";
case 30: return "AK47";
case 31: return "M4";
}
}
function GetWeaponID($name)
{
switch($name)
{
case "None": return 0;
case "9 mm": return 22;
case "Silenced 9mm": return 23;
case "Desert Eagle": return 24;
case "SMG": return 29;
case "Micro SMG": return 28;
case "Tec9": return 32;
case "AK47": return 30;
case "M4": return 31;
}
}
function GetOtherNames11($name1)
{
if($name1 == "None")
{
return "9 mm";
}
if($name1 == "9 mm")
{
return "Silenced 9mm";
}
if($name1 == "Silenced 9mm")
{
return "Desert Eagle";
}
if($name1 == "Desert Eagle")
{
return "None";
}
}
function GetOtherNames12($name1, $name2)
{
if($name1 == "None" && $name2 == "9 mm")
{
return "Silenced 9mm";
}
if($name1 == "9 mm" && $name2 == "Silenced 9mm")
{
return "Desert Eagle";
}
if($name1 == "Silenced 9mm" && $name2 == "Desert Eagle")
{
return "None";
}
if($name1 == "Desert Eagle" && $name2 == "None")
{
return "9 mm";
}
}
function GetOtherNames13($name1, $name2, $name3)
{
if($name1 == "None" && $name2 == "9 mm" && $name3 == "Silenced 9mm")
{
return "Desert Eagle";
}
if($name1 == "9 mm" && $name2 == "Silenced 9mm" && $name3 == "Desert Eagle")
{
return "None";
}
if($name1 == "Silenced 9mm" && $name2 == "Desert Eagle" && $name3 == "None")
{
return "9 mm";
}
if($name1 == "Desert Eagle" && $name2 == "None" && $name3 == "9 mm")
{
return "Silenced 9mm";
}
}
function GetOtherNames21($name1)
{
if($name1 == "None")
{
return "SMG";
}
if($name1 == "SMG")
{
return "Micro SMG";
}
if($name1 == "Micro SMG")
{
return "Tec9";
}
if($name1 == "Tec9")
{
return "None";
}
}
function GetOtherNames22($name1, $name2)
{
if($name1 == "None" && $name2 == "SMG")
{
return "Micro SMG";
}
if($name1 == "SMG" && $name2 == "Micro SMG")
{
return "Tec9";
}
if($name1 == "Micro SMG"&& $name2 == "Tec9")
{
return "None";
}
if($name1 == "Tec9" && $name2 == "None")
{
return "SMG";
}
}
function GetOtherNames23($name1, $name2, $name3)
{
if($name1 == "None" && $name2 == "SMG" && $name3 == "Micro SMG")
{
return "Tec9";
}
if($name1 == "SMG" && $name2 == "Micro SMG" && $name3 == "Tec9")
{
return "None";
}
if($name1 == "Micro SMG" && $name2 == "Tec9" && $name3 == "None")
{
return "SMG";
}
if($name1 == "Tec9" && $name2 == "None" && $name3 == "SMG")
{
return "Micro SMG";
}
}
function GetOtherNames31($name1)
{
if($name1 == "None")
{
return "Silenced 9mm";
}
if($name1 == "Silenced 9mm")
{
return "AK47";
}
if($name1 == "AK47")
{
return "M4";
}
if($name1 == "M4")
{
return "None";
}
}
function GetOtherNames32($name1, $name2)
{
if($name1 == "None" && $name2 == "Silenced 9mm")
{
return "AK47";
}
if($name1 == "Silenced 9mm" && $name2 == "AK47")
{
return "M4";
}
if($name1 == "AK47" && $name2 == "M4")
{
return "None";
}
if($name1 == "M4" && $name2 == "None")
{
return "Silenced 9mm";
}
}
function GetOtherNames33($name1, $name2, $name3)
{
if($name1 == "None" && $name2 == "Silenced 9mm" && $name3 == "AK47")
{
return "M4";
}
if($name1 == "Silenced 9mm" && $name2 == "AK47" && $name3 == "M4")
{
return "None";
}
if($name1 == "AK47" && $name2 == "M4" && $name3 == "None")
{
return "Silenced 9mm";
}
if($name1 == "M4" && $name2 == "None" && $name3 == "Silenced 9mm")
{
return "AK47";
}
}
$link = mysql_connect("ip", "user", "password");
if(!$link) { echo "Cant Connect to Database"; exit(); }
mysql_selectdb("samp");
$query = "SELECT * FROM players";
$result = mysql_query($query);
echo "<form method=\"post\" action=\"admin.php\"";
echo "<input type=\"hidden\" name=\"logged\" value=\"true\">";
echo "<input type=\"hidden\" name=\"pass\" value=\"screwyou\">";
echo "<table width=\"100%\" border=1>";
echo "<tr><td>Name</td><td>Kills</td><td>Deaths</td><td>Money</td><td>AdminLevel</td><td>Gun1</td><td>Gun2</td><td>Gun3</td><td>Save</td></tr>";
$i = 0;
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input type=\"text\" value=".$row['Name']." size=".strlen($row['Name'])." name=\"newName". $i ."\" onchange=\"NameChange(".$i.", this.value)\"></td>";
echo "<td><input type=\"text\" value=". $row['Kills'] ." size=".strlen($row['Kills'])." name=\"newKills". $i ."\" onchange=\"KillsChange(".$i.", this.value)\"></td>";
echo "<td><input type=\"text\" value=". $row['Deaths'] ." size=".strlen($row['Deaths'])." name=\"newDeaths". $i ."\" onchange=\"DeathsChange(".$i.", this.value)\"></td>";
echo "<td><input type=\"text\" value=". $row['Money'] ." size=".strlen($row['Money'])." name=\"newMoney". $i ."\" onchange=\"MoneyChange(".$i.", this.value) \"></td>";
echo "<td><input type=\"text\" value=". $row['AdminLevel'] ." size=".strlen($row['AdminLevel'])." name=\"newAdminLevel". $i ."\" onchange=\"AdminLevelChange(".$i.", this.value)\"></td>";
echo "<td>";
echo "<select name=\"dropGun1".$i."\" onchange=\"SetGun1(".$i.", this.value)\">";
echo " <option value=\"None\">". GetWeaponName($row['Gun1']) ."</option>";
echo " <option value=\"9 mm\">". GetOtherNames11(GetWeaponName($row['Gun1'])) ."</option>";
echo " <option value=\"Silenced 9mm\">". GetOtherNames12(GetWeaponName($row['Gun1']), GetOtherNames11(GetWeaponName($row['Gun1']))) ."</option>";
echo " <option value=\"Desert Eagle\">". GetOtherNames13(GetWeaponName($row['Gun1']), GetOtherNames11(GetWeaponName($row['Gun1'])), GetOtherNames12(GetWeaponName($row['Gun1']), GetOtherNames11(GetWeaponName($row['Gun1'])))) ."</option>";
echo "</select>";
echo "</td>";
echo "<td>";
echo "<select name=\"dropGun2".$i."\" onchange=\"SetGun2(".$i.", this.value)\">";
echo " <option value=\"None\">". GetWeaponName2($row['Gun2']) ."</option>";
echo " <option value=\"9 mm\">". GetOtherNames21(GetWeaponName2($row['Gun2'])) ."</option>";
echo " <option value=\"Silenced 9mm\">". GetOtherNames22(GetWeaponName2($row['Gun2']), GetOtherNames21(GetWeaponName2($row['Gun2']))) ."</option>";
echo " <option value=\"Desert Eagle\">". GetOtherNames23(GetWeaponName2($row['Gun2']), GetOtherNames21(GetWeaponName2($row['Gun2'])), GetOtherNames22(GetWeaponName2($row['Gun2']), GetOtherNames21(GetWeaponName2($row['Gun2'])))) ."</option>";
echo "</select>";
echo "</td>";
echo "<td>";
echo "<select name=\"dropGun3".$i."\" onchange=\"SetGun3(".$i.", this.value)\">";
echo " <option value=\"None\">". GetWeaponName3($row['Gun3']) ."</option>";
echo " <option value=\"9 mm\">". GetOtherNames31(GetWeaponName3($row['Gun3'])) ."</option>";
echo " <option value=\"Silenced 9mm\">". GetOtherNames32(GetWeaponName3($row['Gun3']), GetOtherNames31(GetWeaponName3($row['Gun3']))) ."</option>";
echo " <option value=\"Desert Eagle\">". GetOtherNames33(GetWeaponName3($row['Gun3']), GetOtherNames31(GetWeaponName3($row['Gun3'])), GetOtherNames32(GetWeaponName3($row['Gun3']), GetOtherNames31(GetWeaponName3($row['Gun3'])))) ."</option>";
echo "</select>";
echo "</td>";
echo "<td><input type=\"button\" value=\"Save\" onclick=\"Save(".$i.")\"></td>";
echo "</tr><br/>";
$i++;
}
echo "</form>";
mysql_close($link);
}
else
{
echo "Wrong Pass";
}
}
else
{
echo "<form method=\"post\" action=\"admin.php\">";
echo "<input type=\"password\" name=\"pass\">";
echo "<input type=\"submit\" value=\"Login\">";
echo "</form>";
}
?>
<html>
<head>
<title> DM Server Admin Panel </title>
</head>
<body>
<script language="JavaScript">
var Gun1s = new array();
var Gun2s = new array();
var Gun3s = new array();
var Money = new array();
var Adminlvl = new array();
var Name = new array();
var Kills = new array();
var Deaths = new array();
function SetGun1(var id, var value)
{
Gun1s[id] = value;
}
function SetGun2(var id, var value)
{
Gun2s[id] = value;
}
function SetGun3(var id, var value)
{
Gun3s[id] = value;
}
function MoneyChange(var id, var newvalue)
{
Money[id] = newvalue;
}
function AdminLevelChange(var id, var newvalue)
{
Adminlvl[id] = newvalue;
}
function NameChange(var id, var newvalue)
{
Name[id] = newvalue;
}
function KillsChange(var id, var newvalue)
{
Kills[id] = newvalue;
}
function DeathsChange(var id, var newvalue)
{
Deaths[id] = newvalue;
}
function Save(var id)
{
window.location="admin.php?pass=screwyou&id=" + id + "&Deaths=" + Deaths[id] + "&Kills=" + Kills[id] + "&Name=" + Name[id] + "&Adminlvl=" + Adminlvl[id] + "&Gun1=" + Gun1s[id] + "&Gun2=" + Gun2s[id] + "&Gun3=" + Gun3s[id] + "&Money=" + Money[id];
}
</script>
</body>
</html>