Frontend form add data to database
-
Hi
I’m building a custom plugin to capture customer data.
I have a function that, when called from the front, shows the form – like this (simplified for sake of brevity):function plugin_form() { ?> <form name="customer" method="post" action=""> <input id="name" name="name" value=""/><br/> <input id="surname" name="surname" value=""/><br/> <input id="email" name="email" value=""/><br/> <input type="submit" name="submit" value="submit"/> </form> <?php }
My plugin creates the appropriate database tables during activation.
I have this function to save the data:function save_data() { global $wpdb; $name = $_POST['name']; $surname = $_POST['surname']; $email = $_POST['email']; global $wpdb; $wpdb->query = "INSERT INTO wp_plugin ('name', 'surname', 'email') VALUES ('$name', '$surname', '$email');"; echo 'thanks'; }
The question is:
How do I get the form appearing on the frontpage to call the save_data function in the plugin file?
Any help would be greatly appreciated.
Thanks
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Frontend form add data to database’ is closed to new replies.