josephman1988 Posted August 17, 2008 Share Posted August 17, 2008 Hey guys, I have a problem. I have this form: <form enctype="multipart/form-data" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> Case Name:<br /> <div id="operationupload"> <input type="text" title="casename" name="casename" /></div><br /><br /> Briefing:<br /> <div id="operationupload"> <textarea cols="50" rows="10" name="briefing" title="briefing"></textarea></div><br /><br /> Upload Screenshot:<br /> <div id="operationupload"> <input type="text" name="pictitle" title="pictitle" /><br /> <input type="file" name="imageupload" title="imageupload" /> </div> <br /> <div id="operationupload2" > <?php $sql3 = @mysql_query("SELECT * FROM user_data"); while ($fetch = mysql_fetch_array($sql3)) { ?> <input type="checkbox" name="uid[]" value="<?php echo $fetch['uid']; ?>" /> <a href="../base/user.php?id=<?php echo $fetch['uid']; ?>"><?php echo $fetch['name']; ?></a> <?php } ?> </div> <br /> <input type="submit" value="Submit" name="submit" /> <input type="reset" value="Reset" name="reset" /> </form> I then have this script: if (isset($_POST['casename'], $_POST['briefing'])) { $casename = $_POST['casename']; $briefing = $_POST['briefing']; $pictitle = $_POST['pictitle']; $picname = $_FILES['imageupload']['name']; $sql = @mysql_query("INSERT INTO operation_data SET name = '$casename', briefing = '$briefing', date = CURDATE()"); $lastoid = mysql_insert_id(); $sql2 = @mysql_query("INSERT INTO screenshot_operation SET name = '$picname', title = '$pictitle', operation_dataoid = '$lastoid', date = CURDATE()"); $sql3 = @mysql_query("INSERT INTO user_operation SET operation_dataoid = '$lastoid', user_datauid = '$lastuid'"); if ( isset( $_FILES['imageupload'] ) ) { $_FILES['imageupload']['name']; $_FILES['imageupload']['size']; $_FILES['imageupload']['tmp_name']; $_FILES['imageupload']['type']; $_FILES['imageupload']['error']; basename($_FILES['imageupload']['name']); $source = $_FILES['imageupload']['tmp_name']; $target = "../images/operations/screenshots/".$_FILES['imageupload']['name']; if($_FILES['imageupload']['type'] == "image/pjpeg" || $_FILES['imageupload']['type']=="image/jpeg") { }else{ exit('Permission Denied, Please Only Upload mages'); } if (file_exists($target)) { exit( "File Name Exists, Please Alter" ); } else { move_uploaded_file( $source, $target ); } } } This is what Im doing and trying to do. I have 4 tables. user_data table: -------------- | uid | name | -------------- operation_data table: ----------------------- | uid | name | briefing | ----------------------- user_operation: ----------------------------------- | operation_dataoid | user_datauid | ----------------------------------- screenshot_operation -------------------------- | sid | name | title | date | -------------------------- This form inputs data into the operation_data table, title + briefing, uploads an image to the server including the filepath name and title of the picture to screenshot_operation table. Then the 3rd stage calls an already populated user_data table and prints checkbox fields per user. The queries then grads the operation_datauid that the form will create and applys that to the user_operation table which will relate the operation_datauid with the user_datauid with eachother which populates that table. It succefully inserts the operation_datauid to this table, however, i cant find a way to grab the checked users ids, then insert them into the table ... Any help would be a HUGE help. Thanks, Joe. Link to comment https://forums.phpfreaks.com/topic/120025-solved-inserting-data-using-checkboxes/ Share on other sites More sharing options...
chronister Posted August 17, 2008 Share Posted August 17, 2008 by adding the [] you are turning the checkboxes into an array. So you would use something like this to get to them. <?php $checkbox_array = $_POST['uid']; foreach($checkbox_array as $value) { echo $value.'<br>'; } ?> Link to comment https://forums.phpfreaks.com/topic/120025-solved-inserting-data-using-checkboxes/#findComment-618304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.