I have the following code that is presenting a 'word-of-the-day', As I am relatively new to php coding, I wanted to make sure that there weren't any security issues for how I am selecting from my database from the cookie value. Thanks.
if ($word_of_the_day) {
$wotd = $wpdb->get_results("SELECT term,definition FROM glossary WHERE term = '{$word_of_the_day}'");
foreach ($wotd as $term) { }
}
elseif ($_COOKIE['WOTD']) {
$word_of_the_day = htmlspecialchars(addslashes($_COOKIE['WOTD']));
$wotd = $wpdb->get_results("SELECT term,definition FROM glossary WHERE term = '{$word_of_the_day}'");
foreach ($wotd as $term) { }
}
else {
$wotd = $wpdb->get_results("SELECT term,definition FROM glossary ORDER BY RAND() LIMIT 1");
foreach ($wotd as $term) {
setcookie("WOTD", $term->term, time()+86400);
}
}