Jump to content

Setting it to invalid if it doesnt exist


Xyphon

Recommended Posts

I need to set something to invalid if the $_GET says something wrong. Like if they edit the url to give them whatever weapon, ect they want.

Heres my code so far:

<?PHP
include('Connect.php');
include('top.php');
$ID= $_COOKIE['UserID'];
if(!isset($ID))
{
     echo "Sorry, you must be logged in to view this page";
     include('bottom.php');
     exit;
}
$Result1 = mysql_query("SELECT * FROM users WHERE ID='$ID'");
$Rows1 = mysql_fetch_array($Result1);
$Name2 = $Rows1['Weapon'];
if(isset($_GET['Choice']))
{
     if($_GET['Choice']=="Weapon")
{
          $Result2= mysql_query("SELECT * FROM item_box WHERE Owner_ID='$ID'");
          $Rows2= mysql_fetch_array($Result2);
          $Name= $_GET['Name'];
          $Item_Name= $Rows2['Item_Name'];
          if($Item_Name!=$Name)
     {
               echo "Invalid Selection";
     }
     else
     {
               mysql_query("UPDATE users SET Weapon='{$_GET['Name']}' WHERE ID='$ID'");
               mysql_query("UPDATE item_box SET Type='Weapon', Item_Name='$Name2' WHERE  Owner_ID='$ID' AND Item_Name='{$_GET['Name']}'");
               echo "Item equipped! <a href='itembox.php'>Continue?</a>";
          }
     }
}
else
{

     echo "<b>Weapons:</b><br>";
     $Result2 = mysql_query("SELECT * FROM item_box WHERE Owner_ID='$ID'");
     while($Rows2 = mysql_fetch_array($Result2))
{
          $Name = $Rows2['Item_Name'];
          $Type = $Rows2['Type'];
          if($Type=="Weapon")
{
                echo "<a href=\"itemboxweapons.php?Choice=Weapon&Name=$Name\">$Name<br></a>";

          }
     }
}
include('bottom.php');
?>

 

the problem here is it doesnt loop the data, so it will say invalid data for everyone but the first. If I do loop it will say it like this: If its the first one: Item added! Invalid data if its the second one: Invalid data. Item added! Can you tell me how to do this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.