Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/55991-checking-whether-radio-button-is-checked/
Share on other sites

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.

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

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

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??

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.