Xyphon Posted January 20, 2009 Share Posted January 20, 2009 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? Link to comment https://forums.phpfreaks.com/topic/141659-setting-it-to-invalid-if-it-doesnt-exist/ Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 Where do you want to do it at, here? echo "Invalid Selection"; if so, just add it echo "Invalid Selection"; $invalid = True; Link to comment https://forums.phpfreaks.com/topic/141659-setting-it-to-invalid-if-it-doesnt-exist/#findComment-741534 Share on other sites More sharing options...
Xyphon Posted January 20, 2009 Author Share Posted January 20, 2009 NvM, that wasnt the problem I fixed it myself. Sorry for wasting your time, I should have looked harder beforehand. Link to comment https://forums.phpfreaks.com/topic/141659-setting-it-to-invalid-if-it-doesnt-exist/#findComment-741549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.