graham23s Posted August 25, 2007 Share Posted August 25, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/ Share on other sites More sharing options...
flappy_warbucks Posted August 25, 2007 Share Posted August 25, 2007 change this: <form method="get" action="uploadsneeded"> to this: <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> that should do it Quote Link to comment https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/#findComment-333808 Share on other sites More sharing options...
graham23s Posted August 25, 2007 Author Share Posted August 25, 2007 Hi Mate, tried that to the page just refreshes i don't get the "echo 'uploads code here!'; echoed out or anything. cheers Graham " Quote Link to comment https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/#findComment-333813 Share on other sites More sharing options...
flappy_warbucks Posted August 25, 2007 Share Posted August 25, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/#findComment-333821 Share on other sites More sharing options...
graham23s Posted August 25, 2007 Author Share Posted August 25, 2007 Thanks mate that sounds good. Graham Quote Link to comment https://forums.phpfreaks.com/topic/66628-solved-trying-to-grab-a-get/#findComment-333825 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.