Call PHP Variable Before Its Given A Value?

Hi Guys,

I need your help please, please take a look at some of my code below:

<form id="form1" name="form1" method="post" action="viewaffiliates.php?affid=<? echo $AffID; ?>">
<table width="60%" border="0">
    <td width="28%" class="accountfield">Select Affiliate:</td>
    <td width="72%"><select name="SelectAffiliate" id="SelectAffiliate">
while ($i < $num) {
      <option value="<? echo $AffID; ?>"><? echo $Company; ?></option>
      <input type="submit" name="Submit" id="Submit" value="Select" /></td>

As you can see on the first line above I’m calling a variable called $AffID before its even been given a value. Now i cant add that line of code after the PHP or else it would just create a load of new Forms depending on how many values are in my table.

Can anyone help me please so the value of the selected Option is placed in the Action url please.

Thank you in advance.


why are you passing the same data twice ?

You are adding it into the URL as a GET and then youve got it being selected in teh Select box as a POST.

You should only be using the POST method, like this your top form code wont be calling an undefined variable, thus removing your problem, and only one value (the one selected) will be returned.

Your pickup script will need to look for the POST value rather than the GET.

Erm… I’m not sure why I’ve done that, too much coding today i think its getting to me but yea i see where your coming from.

Changed my code to the correct way how everything should be done and have everything working. Sorry for such a stupid question haha.

Thanks alot!

sometimes it just takes a third eye :eye: