Jump to content

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

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.