Solarpitch Posted November 7, 2007 Share Posted November 7, 2007 Hey Guys, I am trying to write a little script that when the user chooses to edit there ad on the site, it will display a list of there images as thumbnails. They then check a box for the images they want to keep. Is this the correct syntax? //See if the box has been checked $image1checked = isset($_POST['keepimage1']); if ($image1checked == "checked") --> is "checked" the correct state of a checked box if ticked? { //keep image } elseif($image1checked == NULL) { //upload new image code here $image1 = $_FILES['image1']['tmp_name']; } Link to comment https://forums.phpfreaks.com/topic/76378-edit-question-regarding-check-box/ Share on other sites More sharing options...
aschk Posted November 7, 2007 Share Posted November 7, 2007 isset returns a boolean value does it not, so if $_POST['keepimage1'] IS set then $image1check will equal TRUE, and vica versa for NOT set. So BOTH your if statements fail... Link to comment https://forums.phpfreaks.com/topic/76378-edit-question-regarding-check-box/#findComment-386711 Share on other sites More sharing options...
Solarpitch Posted November 7, 2007 Author Share Posted November 7, 2007 So something like this then... if (isset($image1checked) = TRUE) { $image1 = $keep1; } elseif(!isset($image1checked) = FALSE) { $folder = "property_images/"; Link to comment https://forums.phpfreaks.com/topic/76378-edit-question-regarding-check-box/#findComment-386712 Share on other sites More sharing options...
RavenStar Posted November 7, 2007 Share Posted November 7, 2007 No, sometime more like.... if (isset($_POST['keepimage1'])) { // check to see if keepimage1 is set, if it IS, then proceed //keep image } else { //upload new image code here $image1 = $_FILES['image1']['tmp_name']; } Link to comment https://forums.phpfreaks.com/topic/76378-edit-question-regarding-check-box/#findComment-386719 Share on other sites More sharing options...
aschk Posted November 7, 2007 Share Posted November 7, 2007 Edited See ravenstar's post, if it isn't true it's going to be false Link to comment https://forums.phpfreaks.com/topic/76378-edit-question-regarding-check-box/#findComment-386720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.