Seker Posted July 23, 2012 Posted July 23, 2012 With this items system I've been working on, I've realized I have to re-do the shops page as well. Now, while working on the Add Shop Item section of my staffitems page, I've hit a weird problem. When I select the type of item I want to add, this is what shows up as the URL: http://localhost/xampp/v1test/staffitems.php?type=1 As you can see, it's not posting the action at all. I don't understand it, because every other form I've created on the page works just fine. Does anyone see anything wrong with my form code? Or do you think it's something in the code for the rest of the function? $types = array(1 => 'Projectile', 2 => 'Melee', 3 => 'Armor', 4 => 'Energy', 5 => 'Health'); echo " Select the item type to add below:<br /> <form action='staffitems.php?action=addshopitem&type={$_GET['type']}' method='get' /> Item Type: <select name='type'>"; foreach ($types as $id => $name) { echo "<option value='", $id ,"'>", $name ,"</option>"; } echo " </select><br /> <input type='submit' value='Select Type' /></form>"; Quote
Seker Posted July 24, 2012 Author Posted July 24, 2012 (edited) method='get' ... I'll leave it to you to figure it out now :P **EDIT** Okay, using "post" worked. I think I sort of understand why, but.. Yeah. As long as it works. Edited July 24, 2012 by Seker Quote
Lithium Posted July 24, 2012 Posted July 24, 2012 With this items system I've been working on, I've realized I have to re-do the shops page as well. Now, while working on the Add Shop Item section of my staffitems page, I've hit a weird problem. When I select the type of item I want to add, this is what shows up as the URL: http://localhost/xampp/v1test/staffitems.php?type=1 As you can see, it's not posting the action at all. I don't understand it, because every other form I've created on the page works just fine. Does anyone see anything wrong with my form code? Or do you think it's something in the code for the rest of the function? $types = array(1 => 'Projectile', 2 => 'Melee', 3 => 'Armor', 4 => 'Energy', 5 => 'Health'); echo " Select the item type to add below:<br /> <form action='staffitems.php?action=addshopitem&type={$_GET['type']}' method='get' /> Item Type: <select name='type'>"; foreach ($types as $id => $name) { echo "<option value='", $id ,"'>", $name ,"</option>"; } echo " </select><br /> <input type='submit' value='Select Type' /></form>"; FFS... really? Quote
SilverStar Posted July 24, 2012 Posted July 24, 2012 **EDIT** Okay, using "post" worked. I think I sort of understand why, but.. Yeah. As long as it works. How would using the post method work in this situation? You're GETTING information from the URL. Quote
Seker Posted July 24, 2012 Author Posted July 24, 2012 FFS... really? Alright, let's hear what I did wrong, now. Tell me how I've screwed up a simple form. *Sigh* How would using the post method work in this situation? You're GETTING information from the URL. To be honest, the only reason I was going that route is because I wasn't confident $_POST data would hold several form deep. But it does and I got it to work, so no worries. Quote
Lithium Posted July 24, 2012 Posted July 24, 2012 @Seker: I'm not saying you have done anything wrong, mistakes do happen, bw can you code if ut it seems to me for the error you showed, you simply don't know the difference on each... what makes me wonder... how can you code if you can't figure out these simple differences :) Quote
Seker Posted July 24, 2012 Author Posted July 24, 2012 @Seker: I'm not saying you have done anything wrong, mistakes do happen, bw can you code if ut it seems to me for the error you showed, you simply don't know the difference on each... what makes me wonder... how can you code if you can't figure out these simple differences :) Haven't had any problems up until now. As you said, mistakes do happen. The whole rest of the system works just fine. It just seems, when coming to the end of larger projects, that's when the problems come out. Quote
Primed Posted July 26, 2012 Posted July 26, 2012 $types = array(1 => 'Projectile', 2 => 'Melee', 3 => 'Armor', 4 => 'Energy', 5 => 'Health'); echo " Select the item type to add below:<br /> <form action='staffitems.php?action=addshopitem[b]&type={$_GET['type']}[/b]' method='[b]get[/b]' /> Item Type: <select name='type'>"; foreach ($types as $id => $name) { echo "<option value='", $id ,"'>", $name ,"</option>"; } echo " </select><br /> <input type='submit' value='Select Type' /></form>"; You are sort of using both GET & POST methods Personally I would only use POST. So you could remove the extra "&type=....." in the action URL, and you have the form ready to send the type selected to the next page. Just change the method to 'post' and you're flying. Also make sure that 'staffitems.php?action=addshopitem' is waiting to process POST variables rather than GET, I'm not sure which you are looking to use as you have both already in it Quote
Seker Posted July 26, 2012 Author Posted July 26, 2012 You are sort of using both GET & POST methods Personally I would only use POST. So you could remove the extra "&type=....." in the action URL, and you have the form ready to send the type selected to the next page. Just change the method to 'post' and you're flying. Also make sure that 'staffitems.php?action=addshopitem' is waiting to process POST variables rather than GET, I'm not sure which you are looking to use as you have both already in it Yeah, I appreciate it, but I figured it out. Just my mistake thinking the page wouldn't hold on to the POST data a few levels deep. But I got it working exactly as intended. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.