Jump to content
MakeWebGames

Recommended Posts

Posted

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>";
Posted (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 by Seker
Posted
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?

Posted
**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.

Posted
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.

Posted

@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 :)

Posted
@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.

Posted
$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

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...