eagled2 0 Light Poster

First off i'm not quite sure where this post belongs on the forum so I apologize in advance if it's in the wrong place. I have a form in one file that I would like to be processed by another file. The form has a single drop down menu which is populated dynamically with an id number for each entry. The page that is processing the file is also dynamic relying on this id number to know what data to load from the database.

I was previously using a permanent redirect link to make this form load the page and this worked but I now have added some ajax code that makes that method not work as I want. The file with the form I will call form and the other file I will call script. The script file uses a GET variable to load the page in some cases but now needs to load the page based on this form also. I added an if statement that will use the same variable and just change the value depending on whether the form or the GET methods were used. I then changed the form action to the filename of my script.

When I click the button it redirects to the new page using an onclick even added to the button code, but it loads the error I set to load if there is no id. The script simply runs through a series of if statements which check the value of the id variable and if there is none the error is displayed. Here is the related code from my files. I left out the code after the original if statement that checks the id as everything after this is just to display the data and works fine.

form

echo '</td><form action="arttest.php" method="post"><td>
<SELECT NAME=months> 
<OPTION VALUE=0>Choose Month</option>='.$months.' 
</SELECT><input type="submit" name="month" value="Go" onclick="return GB_showFullScreen(\'Articles\', \'http://ldself.com/arttest.php\')"> </td></form>';

script

if (isset($_POST['months'])) {
$aid = $_POST['months'];
}else{
$aid = $_GET['id'];
}

if (isset($aid)) {
Show data
}else{
no id
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.