我目前正在尝试获取提交表单的人的用户名,与他们提交的值一起存储在数据库中。
这是我的函数中的第 139 行:
$retval = $newdb->query("SELECT * FROM $table WHERE user = '$hf_username' ");
Run Code Online (Sandbox Code Playgroud)
add_action("init", "ref_access");
function ref_access() {
global $error;
if ( is_user_logged_in() ) {
global $quanid;
global $newdb;
$hf_username = wp_get_current_user();
$inputValue = isset($_POST['$quanid']);
$newdb = new wpdb( 'user', 'password', 'db', 'localhost' );
$retval = $newdb->query("SELECT * FROM $table WHERE user = '$hf_username' ");
if( mysqli_num_rows($retval) > 0)
{
$newdb->query("UPDATE table SET user = '$hf_username' "); //If user exists, update
}
else
{
global $table;
global $newdb; …Run Code Online (Sandbox Code Playgroud) wordpress ×1