Modify your code like this. It should work now. What you did wrong is both $curQuarter & $curYear is php variable not a part POST. you can directly use them.
<?php
$curMonth = date("m", time());
$curQuarter = ceil($curMonth/3);
$curQuarter = $curQuarter-1;
$curYear = date('Y/m/d', strtotime('-14 day'));
$curYear = date('Y', strtotime($curYear));
if (!empty($_POST)) {
global $wpdb;
$table = wattp2_as_score;
$data = array(
'score_as' => $_POST['yourname'],
'year' => $curYear,
'quarter' => $curQuarter,
);
$format = array(
'%s',
'%s',
'%s',
);
$success=$wpdb->insert( $table, $data, $format );
if($success){
echo 'data has been save' ;
}
} else {
?>
<form method="post">
<input type="text" name="yourname">
<input type="submit">
</form>
Related Posts:
- Theme options not being sent to Database
- MySQL SELECT increment counter
- Exclude Statement in SQL
- Detecting errors generated by $wpdb->get_results()
- wpdb update add current timestamp not working
- Displaying content from one WP site on separate WP site
- Lost the `wp_options` table: what’s the best way to restore the site?
- Can a post ID be 0?
- How to move existing WordPress wp-content folder along with database to new server and new domain name?
- what is the wp_5_posts table in the database?
- Migrating data between local and development server
- WordPress Database Charset/Collate
- How might I retrieve a featured post image from an external WP site and display it as a link back?
- What is the database table for pages?
- Using Dynamic Data Pulled from a MySQL Table in a WordPress Page
- What are conventions about the schema of the $table_prefix
- WordPress database becoming huge. How to analyze and optimize it? fear of running out of memory
- BuddyPress: What’s the use of wp_bp_xprofile_data table and how does it get updated? [closed]
- What’s the most efficient database method to add and query usermeta?
- How to solve slow WordPress site caused by attachment_metadata
- Is database safe after merging a branch of a more recent version over an older one?
- Hook to be used when creating a database table
- Delete all post meta except featured image
- Where is custom template file chosen for a post stored in the DB?
- Large database causes slow load
- Safe way to find last inserted id in a table?
- Database slowdown after update to 3.4.1
- How to insert data into MySQL database from the form created in WordPress site
- Emoji support and MariaDB 10.0.30-
- Is it possible to store visitors IPs in wp_postmeta table?
- I don’t see site_url and home_url fields in wp_options table (phpMyAdmin)?
- Multiple postmeta with same name for one post in wp_postmeta table
- How do I copy a wordpress database?
- Export all content from wordpress
- Import live site to local setup without access to live site
- A field with dashes in the slug [closed]
- Creating a Video Content Page (how to use query strings in wordpress)- Help!
- Form Data not getting stored in WordPress database
- Hook directly into query execution
- Best way to tell if a user account is active, using the database only
- Handling large N data in WordPress
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- Catalina an MAMP Database Conenction Error
- Importing CSV into database table not working?
- A MySQL DB within a MySQL DB
- Is there a way to recover the table wp_term_relationships?
- Trouble Migrating all data blog from WordPress.com to WordPress.org
- “Database Connection Error” upon install in Apache VirtualHost document root.. Why did this happen? [closed]
- How Can I Put Meta_Compare in the Database-Query?
- Historic WordPress database connection
- Change options table prefix only
- What’s the proper way to sanitize checkbox value sent to the database
- $wpdb error (Call to a member function insert() on a non-object)
- Export a custom Mysql database product catalog to WordPress
- Any risk to changing WP table col CHARACTER_MAXIMUM_LENGTH?
- How To Run A Temporary Instance Of a WordPress Backup Without a Database?
- Share users across multiple sites on same database, but with different domains
- Global__r connection timed out
- Should I store critical css in the database or in my theme’s filesystem?
- wp-cli: Error establishing a database connection: undefined constant DB_USER
- Add pdf to a website
- Optimizing function that automatically creates internal links based on post title string
- Woocommerce – Check product stock availability from external database
- Get results from wordpress data custom table
- Outputting query results
- Help With a Large WordPress Based MySQL Database on Shared Hosting
- Database migration issues – Error #1046 No database selected
- Can two domains use the same database?
- Search Character Set Problem
- _wp_attachment_metadata is not being added to database when PDF files uploaded
- How to get the full stack trace for WordPress “table doesn’t exist” error in debug.log?
- How to fix Uploaded to this post option to see group of images uploaded to a post?
- adding user_id and name to a separate table whenever a user register based on role
- How to access a table in a wordpress database using REST API?
- How do I loop/iterate through posts to edit all img tags?
- User saved through WordPress backend does not show up in database table users
- How to edit posts/pages without making the change live?
- How to optimise this database query?
- How to retrieve user data based on role using SQL?
- Adding featured for post using database
- get_the_terms is not working
- Store id from database query in cookie
- Split database on large site?
- Store the wordpress “featured image” under »wp_posts« Database table
- Return image urls with specific base string?
- What WordPress file is saving new users to database
- wordpress database error
- Restoring .sql backup results in “Error establishing a database connection”
- Link to handle $_GET request
- WordPress sync with phpbb
- “MySQL server has gone away” since update to 3.8
- Getting deleted users in database
- Getting data from a table using a query
- Database interaction (private-public) [closed]
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL query to rewrite all media URLs to end with .webp
- wp-config was suddenly updated
- Many images in wp-content/uploads folder that are not in Media Library
- Order of search results based off of a backend custom field and also in alpha order
- How to find fresh (last modified) and sql backup?