Jump to content

bpgilly

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by bpgilly

  1. In my other topic... Seems i only have 2 posts on this forum... And i'm not really copy pasting i'm looking around reading code and trying to understand it, then i use it in my website and try to get it right, where i bumped into this problem and another one wich i'm trying to find myself to...
  2. I fixed the problem. I had to make an action to a different page. I was trying to get my whole website into home.php and just work with include and require_once to get everyting one home.php. I just made a new page called store.php with my layout copied and copied my code there, then i did everyting you told me and it works fine now. Thanks!
  3. Hi i'm making a new website based on PHP. I bumped on a problem now... The problem is that I have a loop where i get all records out of my sql database and get them into a form. Every record has a differend form with a button to. Every button then has a unique ID. Now i tried everyting i could think of to get the value out of a button when a button is clicked. But nothing worked... here is the part of the code where everything is for the form and the POST. while($record = mysql_fetch_object($result)){ $id = $record->id; echo"<form action='home.php' method='post'>"; echo"<b>name:</b>".$record->name." <b>Price: </b>".$record->price.""; echo'<input type="hidden" name="id" value='.$id.'>'; echo"<input type='submit' value='Buy' /><br />"; echo"</form>"; } if($_POST) { $ID = intval($_POST['id']); $query1 = "SELECT price FROM items WHERE id = ".$ID.""; $result1 = mysql_query($query1); list($cost) = mysql_fetch_row($result1); $gold = getStat('gc',$userID); if($gold > $cost) { setStat('gc',$userID,($gold - $cost)); $queryw = "INSERT INTO users_inventory(item_id,user_id, quantity) VALUES ('".$ID."','".$userID."','1')"; $resultw = mysql_query($queryw); } else { echo"You can't afford this weapons."; } } The only thing that doesn't seem to work is this part $ID = intval($_POST['id']); is always gives me this error: Notice: Undefined index: id in shop.php on line 26 Please help me out here i have no idea what to do from here on...
×
×
  • 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.