jesushax Posted April 3, 2009 Share Posted April 3, 2009 hi all my code below, updates my table according to form data it recieves, what ive found out though, if a user unticks a checbox or deltes text in a field, the data is not posted so a user cant update any checkboxes, is there away that a form can post all its fields even if the field has nothing in it? i know if i put each post in a variable i can do it that way becuase the variable will be empty but a way for the below code to work, the whole point of my code below was to save me typing out 100s of variables Cheers case "part5"; $ID = $_SESSION["DirectoryID"]; $posts = $_POST; $SQL = "UPDATE tblDirectory2 SET "; foreach($posts as $key=>$value){ $SQL .= "`".mysql_real_escape_string($key)."`='".mysql_real_escape_string($value)."', "; } $SQL = rtrim($SQL,", "); $SQL .=" WHERE `CompanyID`='$ID'"; echo "<p>".$SQL."</p>"; mysql_query($SQL) or die (mysql_error()); header("Location: /new_directory/reg_completed.php"); exit(); break; Link to comment https://forums.phpfreaks.com/topic/152350-posting-form-data-if-fields-arent-filled-in-or-ticked/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.