I'm trying to build (my first) a basic WordPress plugin that stores form data and one of the options I need is the ability to delete old form data. I've been experimenting with trying to get a simple query to work, but I keep getting an error message. The error reads ' Fatal error: Call to a member function query() on a non-object in /home/.. on line 5'
So in theory when I click submit it should delete the post. Am I way off? Any help is greatly appreciated.
Plugin admin page -
<h1>Form Data</h1>
<form action="next.php" method="post">
<input type="submit">
</form>
Next.php
<?php
global $wpdb;
$wpdb->query( $wpdb->prepare( "DELETE FROM wp_posts WHERE ID = 42" ) );
?>