dongpi0658 2015-08-20 21:02
浏览 52
已采纳

PHP表单只返回空数组

I am working on a code segment that is a messaging function next to a list of names. On the page there is an envelope and when you click it a pop-up window appears with a text area inside of it. I would like to be able to fill that textarea with characters and send it as a message using my already functioning sendMessage function. I know my sendMessage function works and I've isolated the issue to the return given by the submit button. How do I get my submit button to POST the textarea to the page (keep in mind there are 2+ forms on this page). The code looks like this:

if (empty($_POST) === false) {
    print_r($_POST);
    $blah = $_POST;
    echo "<script>window.top.location='asd.$blah'</script>"; 
}

if (empty($_POST['Send']) === false) {

    echo "<script>window.top.location='../hidden/PNMasdd.php?gpa=$var1&year=$var2&major=$var3&sport=$var4'</script>";
    echo 'YOU ARE IN THE SENDING MESSAGE FIELD';

    if( empty ($_POST['message_full']))
        {
            $errors[] = 'All fields must be filled in!';
            //print_r($errors);
        }

    if(empty($_POST) === false && empty($errors) === true)
        {
            $receiver_id = $temp_user['id'];
            $sender_id   = $user_data['id'];

            $type = 0;

            if(empty($is_Convo))
                {
                    $is_Convo = 0;  
                }

            $blahVar = $user_data['id'] . ',';
            $message = str_replace("
", "<br>", $_POST['message_full']);
            $message_data = array(
                                  'sender_id'               => $user_data['id'],
                                  'receiver_id'         => $receiver_id,
                                  'message_full'            => $message,
                                  'is_opened'               => $blahVar,
                                  'isConvo'             => $is_Convo,
                                  'type'                    => $type
                                  );
            //Put data limit code here

            send_message($message_data);
            $my_exten = "Messages/messages.php";
            $noti_data = array(
                               'id_receive'         => $receiver_id,
                               'id_sent'                => $user_data['id'],
                               'type'                   => 1,
                               'exten'                  => $my_exten   
                               );
            notify($noti_data);

            echo '<center>';
            echo '<div class="alert alert-info">
                          <strong>It sent!</strong> You have sent a message successfully!
                  </div>
        ';
            echo '</center>';
        }
    else{
        echo output_errors($errors);
    }
}   

?>

<form id="wow" name="wow" action="" method="POST">
    <div class="row">

    </div>
    <div class="row">
    <div class="form-group">
    <div class="col-md-12">
    <center>
    <textarea maxlength="100000" data-msg-required="Please enter your message." rows="10" cols="100%" class="form-control" name="message_full" id="message_full"></textarea>
    </center>
    </div>
    </div>
    </div>

</form>

</div>
<div class="modal-footer">
<table width=90%><td width=45%><button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button></td><td width=45%> 

<button type="submit" value="Send Message" name="Send" onclick="document.getElementById('wow').submit()" class="btn btn-primary">Send</button>
  • 写回答

2条回答 默认 最新

  • dongshi7350 2015-08-20 21:57
    关注

    As pointed out in the comments, the buttons need to be inside your form.

    Your setup is a bit odd for my taste, but try this out.. it will mostlikely need some tweaks and i'm not sure about the cancel button..

      <form id="wow" name="wow" action="" method="post" >
        <div class="form-group required">
          <div class="col-md-12">
            <textarea name="message_full" id="message_full" rows="10" cols="100%" class="form-control" maxlength="10000" placeholder="Please enter your message." autocomplete="off"></textarea>
          </div>
        </div>
    
    
        <div class="buttons"> <!-- add css for this or change the class to yours.. -->
            <input class="btn btn-default" data-dismiss="modal" value="Cancel" />
            <input class="btn btn-primary" type="submit" value="Send Message" />
        </div>
      </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集