Jump to content

Recommended Posts

		$result = safe_query("SELECT * FROM ".PREFIX."cup_clan_members WHERE userID = '".$userID."' AND function = 'Leader'");		
	$clan = '<option value="0" selected="selected"> - '.$_language->module['choose_team'].' - </option>';		
	while($dm=mysql_fetch_array($result)) {
		$clan .= '<option value="'.$dm['clanID'].'">'.getclanname($dm['clanID']).'</option>';
                        $clanID = $dm['clanID'];
            }

 

<form method="get" action="clans&action=clanregister&cupID='.$dl['ID'].'"><select name="clanID">'.$clan.'</select><input type="submit" value="Go"></form>

 

Output: clans&action=clanregister&cupID=<ID>?clanID=<ID>

Needed output: clans&action=clanregister&cupID=<ID>&clanID=<ID>

 

I get correct outputs for both IDs also.

 

I tried:

 

<form method="get" action="clans&action=clanregister&cupID='.$dl['ID'].'&clanID='.$clanID.'"><select>'.$clan.'</select><input type="submit" value="Go"></form>

but it doesn't select correct clanID from dropdown.

 

anyone can help please?

 

Link to comment
https://forums.phpfreaks.com/topic/196736-simple-form-question/
Share on other sites

It looks like you're trying to put a form value into the ACTION attribute of the <FORM> tag.  You don't need to do that.  Instead, use HIDDEN fields.

 

Not tested...

<input type="hidden" name="action" value="clanregister">
<input type="hidden" name="cupID" value="myValueHere">

 

Then remove the extra values you have in your ACTION attribute and only have the page name there.

I've also tried:

 

<form action="index.php?"><select name="site">
<option value="clans&action=clanregister&cupID='.$dl['ID'].'&clanID='.$dm['clanID'].'">

 

Output: index.php?site=clans%26action%3Dclanregister%26cupID%3D23%26clanID%3D325

:S

 

%26 = "&"

%3D = "="

Thanks but everytime I use <select name="clan"> it will end up like this: index.php?site=clans?clan=325

 

That's because it takes the first name/value pair it finds and attaches a ? to it after the page name.  All other name/value pairs after that will have &.  The ACTION attribute should only have the page name; remove any ? or & it has.  You never have to manually add in ? or &, the form will do it for you.  On any form tags, the NAME attribute should have a name only, and the VALUE attribute should have a single value only; no mixing and adding of multiple values with ? and &.

 

Not tested...

<form action="index.php">
  <select name="site">
      <option name="clanID" value="{$dm['clanID']}'">
  </select>
   <input type="hidden" name="cupID" value="{$dl['ID']}">
   <select type='hidden' name='action' value='clanregister'>
</form>

 

 

I'm assuming that you don't have multiple values for cupID for each form.  Basically, your loop would generate more <option></option>.

Something new..

 

$teamID = $dm['clanID'];
<form action="index.php"><select name="site">'.$clan.'</select>
<input type="hidden" name="action" value="clanregister"><input type="hidden" name="cupID" value="'.$dl['ID'].'">
<input type="hidden" name="clanID" value="'.$teamID.'"><input type="submit" value="Go"></form>

 

$clan .= '<option name="clanID" value="clans">'.getclanname($dm['clanID']).'</option>';

 

Everything is ok except clanID is incorrect because option value is not $dm['clanID']

No one? is there something else I can use then? java links for dropdowns.. ? so I can type in my own custom URL without these annoying "?" getting on the way. :( :( more complicated now than simple.

 

Closest:

 

index.php?site=325&action=clanregister&cupID=24&clanID=325 <CORRECT ID>

<option value="'.$dm['clanID'].'">'.getclanname($dm['clanID']).'</option>

 

Or...

 

index.php?site=clans&action=clanregister&cupID=24&clanID=<INCORRECT ID> because option value is not $dm['clanID']

<option value="clans">'.getclanname($dm['clanID']).'</option>

 

understand better?

 

You where on the right track the correct is:

 

<form action="index.php">
<input type="hidden" name="site" value="clans">
<input type="hidden" name="action" value="clanregister">
<input type="hidden" name="cupID" vlaue="<?php echo $dl['ID']; ?>">
<select name="clanID">
    <option><?php print $clan; ?></option>
</select>
<input type="submit" value="Go">
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

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.