troubleshooting Question

filter $_POST in PHP pdo

Avatar of Alex Lord
Alex Lord asked on
DatabasesPHP* POST* PDO
11 Comments1 Solution126 ViewsLast Modified:
foreach($_POST as $key => $val){
			
			$k = $key;
			$v = $val; 
			if($v=='NULL'){
	
				/*$stmt = new Database();
				
				$query = "UPDATE TXT2GIVE_CONTACTS SET :k = :v WHERE ID = :contactId";
				$stmt->query( $query );
				$stmt->bind( ':k', $k);
				$stmt->bind( ':contactId', $contactId );
				$stmt->bind( ':v', $v);
				$stmt->execute();
				$result = $stmt->all(); */
				$updatedFields = "v is null";

			} else {
				$updatedFields = "v is not empty";

				$stmt = new Database();

				$query = "UPDATE TXT2GIVE_CONTACTS SET :k = :v WHERE ID = :contactId";
				$stmt->query( $query );
				$stmt->bind( ':k', $k);
				$stmt->bind( ':contactId', $contactId );
				$stmt->bind( ':v', $v);
				$stmt->execute();
				$result = $stmt->all();
			} 



here is my statement, so as u see it goes into the $_POST and uses these to update the database,  however i also have a field within $_POST that isnt in that database such as subaction which triggers the case this code is currently sitting,  how can i remove these from the $_POST ? or filter them ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros