drz49609 2018-04-26 23:36
浏览 171
已采纳

在表单中调用php函数 - wordpress

im trying to call a php function in submiting a form.

here my full php file: ( am i write correct? )

<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
?>
    <div class="manual_sending_form" id="manual_sending_form">

        <div class="inside">
            <form class="initial-form" id="manual_sending" method="post" name="post"
                  action="<?php echo admin_url( 'admin.php?page=my-page' ) ?>">

                <p>
                    <label for="resive_number">My Field</label><br>
                    <input type="text" name="resive_number" id="resive_number"
                           value="<?php echo isset( $_POST['sms_numbers'] ) ? sanitize_text_field( $_POST['sms_numbers'] ) : '' ?>"
                </p>


                <p>
                    <input type="submit" class="button button-primary" name="send_sms_button"
                           value="Send">
                </p>
            </form>
         </div>
    </div>


<?php
if ( isset( $_POST['send_sms_button'] ) ) {
    try
    {
        $phone = $_POST['sms_numbers'];

// do some code hwre
?>

did i correct on below line? i just want to input something there ( i need this value on function.

 value="<?php echo isset( $_POST['sms_numbers'] ) ? sanitize_text_field( $_POST['sms_numbers'] ) : '' ?>"

or this part is correct ? ( $phone = $_POST['sms_numbers']; )

i dont know why i get below error, //// Notice: Undefined index: sms_numbers in

  • 写回答

1条回答 默认 最新

  • douman6245 2018-04-26 23:51
    关注

    Try to replace your code into this

    <input type="text" name="sms_numbers" // change input name to sms_numbers

    and set this line at the top of your page

    ini_set('display_errors',0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题