Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $\u POST不更新值_Php_Html_Wordpress - Fatal编程技术网

Php $\u POST不更新值

Php $\u POST不更新值,php,html,wordpress,Php,Html,Wordpress,当前正在尝试使用表单更新定义的值,但对我无效。 我尝试了几件事,甚至是在另一个页面上使用+1更新值的函数,所以我不确定我的表单有什么问题 <?php if(isset($_POST['submitcounter'])){ function mail_counter(){ $val = $_POST['test']; //Increment the current count update_option(CF7_COUNTER, $val); //Update the se

当前正在尝试使用表单更新定义的值,但对我无效。 我尝试了几件事,甚至是在另一个页面上使用+1更新值的函数,所以我不确定我的表单有什么问题

<?php

if(isset($_POST['submitcounter'])){
function mail_counter(){
    $val = $_POST['test']; //Increment the current count
    update_option(CF7_COUNTER, $val); //Update the settings with the new count
}
}


/*
function update_counter(){
update_option(CF7_COUNTER, (int) $_POST['test']);
}
*/

?>

<h1>Settings Page</h1>

<form method="post" action="" >

    <label for="Settings_text">Settings</label>

    <input type="number" name="test" value="<?php echo get_option(CF7_COUNTER); ?>"/> 
    <input type="submit" name="submitcounter" value="update"  class="button button-primary button-large">
</form>

设置页面
设置

您必须删除mail_counter()函数

您必须删除mail_counter()函数

您需要调用该函数,因为代码写在函数体中,控件不在其中:

if (isset($_POST['submitcounter'])) {
 function mail_counter(){
  $val = $_POST['test']; //Increment the current count
  //Update the settings with the new count
  update_option(CF7_COUNTER, $val);    
 }
 mail_counter(); // This function is defined but not called.
}

您需要调用函数,因为代码写在函数体中,而控件不在其中:

if (isset($_POST['submitcounter'])) {
 function mail_counter(){
  $val = $_POST['test']; //Increment the current count
  //Update the settings with the new count
  update_option(CF7_COUNTER, $val);    
 }
 mail_counter(); // This function is defined but not called.
}

设置页面
设置

设置页面
设置

您没有调用已定义函数的函数。您没有调用已定义函数的函数。谢谢^I复制了某个示例,但没有考虑到这一点。谢谢^I复制了某个示例,但没有考虑到这一点。不客气!如果这确实回答了您的问题,您是否可以将其标记为已回答。:)当然,你能告诉我在哪里可以把它标记为完成并不是很明显。我可能会做
if(isset($\u POST['submitcounter'])和&isset($\u POST['test']){}
,以确保捕捉到潜在的错误,不客气!如果这确实回答了您的问题,您是否可以将其标记为已回答。:)当然,你能告诉我在哪里可以把它标记为完成并不是很明显。我可能会做
if(isset($\u POST['submitcounter'])和&isset($\u POST['test']){}
,以确保捕捉到潜在的错误