像这样修改代码。现在应该可以了。你做错的是$curQuarter &;$curYear 是php变量,不是part POST。您可以直接使用它们。
<?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>