ryan.od Posted June 18, 2007 Share Posted June 18, 2007 I want to check a file upload against a radio button selection (i.e. if the site owner doesn't upload product x, they cannot feature product x). I tried this, but it won't work. Any help would be appreciated: else if(empty($_FILES['image_w']['name'])){ if($_POST['featured'] == 'w'){ $errors[7] = 1; } } The $_FILES['image_w'] field MUST be filled in if you want to select the radio button with name='w'. This, however, doesn't work. Why not? RyanOD Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/ Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 cool i dont get it elaborate more plzzz Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276555 Share on other sites More sharing options...
ryan.od Posted June 18, 2007 Author Share Posted June 18, 2007 Ok, so there is a form where the admin can submit images and select one of the images to be a 'featured' image. The images are chosen with image text boxes (you know, with the Browse button next to them) while the 'featured' image is chosen with a radio button. As a result of my design choices (bad, I know, but no time to fix properly), an admin could choose to feature an image that he/she did not upload as all choices (white, red, black, green, etc. . .these images are shirts) are available in the radio button group. To sum up, the issue is this: an admin could upload the red, green, and orange versions of a shirt, but accidentally choose to feature the white shirt. . .this is the problem I am trying to catch. Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276571 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 wait if your trying to say that the user or the admin can only choose between those image that u have then u dont have to use the move upload system coz whats the ue of it when you are limiting there privileges remember that when you use move upload u are free to browse an image say i can put there my on image so i guess if thats what you are trying to do put them as as check boxes options am i helping you Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276579 Share on other sites More sharing options...
ryan.od Posted June 18, 2007 Author Share Posted June 18, 2007 I appreciate your insight and it is most definitely valid. . .however, I'm not doing a very good job explaining the situation. Rather than bounce stuff back and forth, can you look at the code on the first post and tell me whether or not the way to check a group of radio buttons to see which one is selected is to check if($_POST['radio_name'] == 'radio_value')? I think that is the real question here. Thanks again for the comments you have left. And sorry for the complexity of this simple question! RyanOD Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276589 Share on other sites More sharing options...
hackerkts Posted June 18, 2007 Share Posted June 18, 2007 Hmm what about something like this <input type="radio" value="w" name="featured"> <?php if ($_POST['featured'] == 'w') { // it was selected } Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276594 Share on other sites More sharing options...
ryan.od Posted June 18, 2007 Author Share Posted June 18, 2007 This is what I have currently: <input type="file" name="image_w" size="50" /> <input type="radio" name="featured" value="w" /> <?php if(empty($_FILES['image_w']['name'])){ if($_POST['featured'] == 'w'){ $errors[7] = 1; } } ?> However, the second 'if' statement does not work. . .thoughts?? Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276597 Share on other sites More sharing options...
hackerkts Posted June 18, 2007 Share Posted June 18, 2007 You will have to check if(empty($_FILES['image_w']['name'])){ Quote Link to comment https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/#findComment-276604 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.