jedimastafez Posted November 13, 2006 Share Posted November 13, 2006 Hi guys, I normally wouldnt ask for help but I have googled this for a week and none of the stuff I found seem to fit what I need.So if anyone can help with this it would be greatly appreciated.Im doing a family photo album and have the forms all set up but have come across one small problem.I have the form display five fields for five photo uploads, they write a caption for the photo, select the photo and check a radio button if they wish the photo to be the "Cover" photo for the current album they are uploading it too.The problem I have is the form calls "upload.php" which grabs all the necessary values from POST, but I am stuck as to how to grab the value pertaining to which radio button is checked.Does anyone know how best to do this? All I can find is a javascript but if I do that how do I translate the returned javascript function value into a php variable to be sent through POST and retrieved in the upload.php form.Again any help you could offer would be awesome. Link to comment https://forums.phpfreaks.com/topic/27083-getting-radio-button-values-from-post/ Share on other sites More sharing options...
impulse() Posted November 13, 2006 Share Posted November 13, 2006 [code]echo $_POST["<radio button name>"];[/code]? Link to comment https://forums.phpfreaks.com/topic/27083-getting-radio-button-values-from-post/#findComment-123857 Share on other sites More sharing options...
hostfreak Posted November 13, 2006 Share Posted November 13, 2006 Name the radio buttons the same, but give them different values.e.g:[code]<input type="radio" value="Cover" name="type"><input type="radio" value="Non-Cover" name="type">[/code]Then on form.php:[code]$type = $_POST['type'];[/code] Link to comment https://forums.phpfreaks.com/topic/27083-getting-radio-button-values-from-post/#findComment-123859 Share on other sites More sharing options...
jedimastafez Posted November 14, 2006 Author Share Posted November 14, 2006 thanks for the suggestions guys, impulse() I already tried that. It doesnt print out anything when I do that. Ofcourse I have not set the values to anything which leads me to your pointer hostfreak.I cant assign a "cover" "non cover" thing because I dont know which they will pick to be the eventual coverHere is the HTML[code]<div id="addPhoto"> <br> <input type="hidden" name="photoNumber0" value="new"> Caption:<br> <input type="text" name="photoCaption0" size="60"><br> File:<br> Is Cover Image: <input type="radio" name="isCover" checked> <input type="file" name="photoFile0"><br> <input type="hidden" name="photoNumber1" value="new"> Caption:<br> <input type="text" name="photoCaption1" size="60"><br> File:<br> Is Cover Image: <input type="radio" name="isCover"> <input type="file" name="photoFile1"><br> <input type="hidden" name="photoNumber2" value="new"> Caption:<br> <input type="text" name="photoCaption2" size="60"><br> File:<br> Is Cover Image: <input type="radio" name="isCover"> <input type="file" name="photoFile2"><br> <input type="hidden" name="photoNumber3" value="new"> Caption:<br> <input type="text" name="photoCaption3" size="60"><br> File:<br> Is Cover Image: <input type="radio" name="isCover"> <input type="file" name="photoFile3"><br> <input type="hidden" name="photoNumber4" value="new"> Caption:<br> <input type="text" name="photoCaption4" size="60"><br> File:<br> Is Cover Image: <input type="radio"name="isCover"> <input type="file" name="photoFile4"><br> <input type="submit" onClick="" value="Add photo"> </div>[/code]And a screenshot (this is only a rough design and layout)[img]http://img297.imageshack.us/img297/7636/uploadformmj3.jpg[/img]when it comes time to grab the value from the radio buttons from POST I use this[code]$isCover = $post_safe["isCover"]; echo $post_safe["isCover"];[/code]Where $post_safe is the original POST data with slashes addedany other suggestions? Link to comment https://forums.phpfreaks.com/topic/27083-getting-radio-button-values-from-post/#findComment-124333 Share on other sites More sharing options...
Fearpig Posted November 14, 2006 Share Posted November 14, 2006 You could try this..... :-\Form.html[code]//Image and other data<input type='radio' name='WhichImage' value='Photo1'>Use as Thumbnail//Image and other data<input type='radio' name='WhichImage' value='Photo2'>Use as Thumbnail//Image and other data<input type='radio' name='WhichImage' value='Photo3'>Use as Thumbnail//Image and other data<input type='radio' name='WhichImage' value='Photo4'>Use as Thumbnail//Image and other data<input type='radio' name='WhichImage' value='Photo5'>Use as Thumbnail[/code]Processing.php[code]if (!isset($_POST['WhichImage'])){ $WhichImage = "Photo1";}//If WhichImage variable is not set, default to Photo1 for the thumbnailelse { $WhichImage = $_POST['WhichImage'];}//Otherwise use the WhichImage variable[/code]Sorry not checked my code but I'm fairly sure this works in theory!! Link to comment https://forums.phpfreaks.com/topic/27083-getting-radio-button-values-from-post/#findComment-124381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.