Jump to content

[SOLVED] Trying to grab a GET


graham23s

Recommended Posts

Hi Guys,

 

this is a small portion of the code im having trouble with:

 

                </tr>
                <tr>
                <td align="right" /><b>Upload File</b></td><td align="left"><input type="file" name="file"><form method="get" action="uploadsneeded">
                                                                                                          <select name="uploadsneeded">
                                                                                                          <option value="2">2</option>
                                                                                                          <option value="3">3</option>            
                                                                                                          </select>
                                                                                                          <input type="submit" name="action" value="Go!">
                                                                                                          </form>
                </td>
                </tr>';
?>
<?php
## how many uploads needed ##############################################################
if($_GET['action'] == 'uploadsneeded') {

echo 'uploads code here!';
exit;

}
?>

 

there is a drop down box which has the value 2 or 3, this dictates how many files the user wants to upload, but im having trouble , after the Go! button is pressed i was trying to get the GET action below to catch the code but its  not doing it, can anyone see where i have went wrong?

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/
Share on other sites

Well in your code your refering to the object name and not the value.

 

                </tr>
                <tr>
                <td align="right" /><b>Upload File</b></td><td align="left"><input type="file" name="file"><form method="get" action="$_SERVER['PHP_SELF']; ?>">
                                                                                                          <select name="uploadsneeded">
                                                                                                          <option value="2">2</option>
                                                                                                          <option value="3">3</option>            
                                                                                                          </select>
                                                                                                          <input type="submit" name="action" value="Go!">
                                                                                                          </form>
                </td>
                </tr>';
?>
<?php
## how many uploads needed ##############################################################
if($_GET['action'] == 'uploadsneeded') {

echo 'uploads code here!';
exit;

}
?>

 

In your condition your asking if the value of action (which is your submit button) is equal to the name of the select object.

 

you need to check the value of the select object (uploadsneeded) and then compare that in the get.

 

So...

 

What i would do is in the statement i would say:

 

$x=$_GET['uploadsneeded'];
switch($x)
{
    case 1:
        //code for 1 upload;
        break;
//do this over the amount of upoads your willing to offer
}

if (!isset($_GET['uploadsneeded']))
{
    /* use this as the code that will go to your start function as anything that goes in here will be executed if the uploadsneeded varible is not set*/
}

 

try something along them lines :)

Archived

This topic is now archived and is closed to further replies.

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