I have a simple routine that deletes a row from an SQL database..
<?php
global $wpdb, user_ID;
$tmp_mid = $_GET['mid'];
if (!empty($tmp_mid))
{
$id_check = $wpdb->get_var($wpdb->prepare("SELECT message_to_user_ID FROM " . $wpdb->base_prefix . "messages WHERE message_ID = %d", $tmp_mid));
if ( $id_check == $user_ID )
{
$wpdb->query( $wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . "messages WHERE message_ID = %d", $tmp_mid ));
}
}
?>
I want to ensure that the row can only be deleted if the $user_ID matches the $tmp_mid from the row. All seems to work correctly but is this routine vulnerable to SQL injection?
Do I need to do anything to it to secure it?