Write a row to database table with button or link
-
When someone clicks a specific button on my page i’m looking to grab a few pieces of data (user name, date/time, URI, etc.) and write a row into a table I created in the wordpress mySQL database.
I can successfully write to my database using this:
<?php global $wpdb; // Get URL $Path=$_SERVER['REQUEST_URI']; $URI='https://www.example.com'.$Path; // Get Current User $user = wp_get_current_user(); // Inject row into custom_table $wpdb->insert( 'custom_table', array( 'user' => $user->user_login, 'page' => $URI, 'vote' => 6, 'date' => current_time('mysql')), array( '%s', '%s', '%d', '%s' ) ); ?>
However I want to turn it into a button.
Can anyone here lead me in the right direction?
- The topic ‘Write a row to database table with button or link’ is closed to new replies.