HTML/PHP - default input value

前端 未结 10 1339
梦如初夏
梦如初夏 2020-12-11 16:48

I have a post php form and a set of inputs:

  1. Your Name
  2. Your Last Name
  3. My Name

Every input looks the same, only the names change

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 17:36

    you can change the get_option() function to be something like

    function get_option($name) {
       $defaults = array(
          'fist_name' => 'Mike',
          'fist_name' => 'Wordpressor',
          'my_name' => 'Dunno'
       );
       // get the value from the $defaults array
       $val = $defaults[$name];
    
       // but if the same value has already been posted - replace the default one
       if (isset($_POST[$name])) {
          $val = $_POST[$name];
       }
       return $val;
    }
    

提交回复
热议问题