【问题标题】:How to get the values from the form to my php segment? My php segment does not recognize the submit button如何从表单中获取值到我的 php 段?我的 php 段无法识别提交按钮
【发布时间】:2019-03-29 03:10:50
【问题描述】:

我有一个表单,它从用户那里获取数据并将其发送到 php,但问题是当单击提交按钮时,php 段无法识别它。我在做什么错误?任何帮助将不胜感激。

我已经写了这段代码,请检查它..

 <form  action="dash.php" method="post" id="msform">

        <ul id="progressbar">
          <li class="active">About</li>
          <li>Details</li>
          <li>Submission</li>
        </ul>

        <fieldset class="first">
          <!-- <h2 class="fs-title">SignIn</h2> -->
          <h3 class="fsf-subtitle">About Blood-Camp</h3><br>
          <input type="text" name="email" placeholder="Contact Email" required/>
          <input type="text" name="number" placeholder="Contact Number" required/>
          <input type="text" name="name" placeholder="Contact Person Name" required/>
          <input type="button" name="next" class="next firstbutton action-button" value="Next" />
        </fieldset>
        <fieldset class="second">
          <!-- <h2 class="fs-title">Topic</h2> -->
          <h3 class="fsf-subtitle">Details about Blood-Camp</h3><br>
          <input type="text" name="city" placeholder="City" required/>
          <input type="text" name="address" placeholder="Address" required/>
          <input type="text" name="date" placeholder="Date" required/>
          <input type="text" name="time" placeholder="Timing" required/>

          <input type="button" name="previous" class="previous action-button" value="Previous" />
          <input type="submit" name="submit" class="next secondbutton action-button" value="Submit" />
        </fieldset>

        <fieldset class="third">
          <!-- <h2 class="fs-title">Topic</h2> -->
          <h3 class="fsf-subtitle">Thank You:)</h3><br><hr><br>
          <h4> Organization Name:-</h4><br>
          <h4> Contact No:-</h4><br>
          <h4> Email:-</h4><br>
          <h4> Address:-</h4><br>
          <h4> City:-</h4><br><hr><br>
            <h4>Your Blood Camp Details Will Be Updated And Everyone Will Get Notified Within 24 Hours Of Time.</h4><br><hr><br>
          <h4> Your Organization Is Creating a Deep Impact On Society :) </h4>


        </fieldset>


      </form>

    </section>

    </div>

    <script>

    var parent, next_fs, previous_fs;



    $(".next").click(function(){
      parent = $(this).parent();
      next_fs = $(this).parent().next();
      prev_fs = $(this).parent().prev();
      $(parent).hide();
      $(next_fs).show();
      $("#progressbar li").eq($("fieldset").index(parent)).addClass("active");
       // $("#progressbar li").eq($("fieldset").index(parent)).removeClass("active");

     });

     $(".previous").click(function(){
       parent = $(this).parent();
       prev_fs = $(this).parent().prev();
       $(parent).hide();
       $(prev_fs).show();
       // $("#progressbar li").eq($("fieldset").index(prev_fs)).addClass("active");
       $("#progressbar li").eq($("fieldset").index(prev_fs)).removeClass("active");

     });
     </script>
    </body>


    </html>

    <?php

        include('../dbcon.php');

        if(isset($_POST['submit'])){


           echo('divesh'); 

?>

我希望至少在单击提交时,php 段会识别它

【问题讨论】:

  • 你的PHP代码在dash.php吗?
  • 您在关闭 html 标记后回显。您不会在页面上看到任何内容。您必须查看页面源代码才能看到。
  • 是的,这段代码在 dash.php 中,即使在关闭 html 标记后回显后,也没有任何反应

标签: php html web


【解决方案1】:

假设表单在 dash.php 页面中,将您的 php 代码移动到 html 的正文中。

<html>
  <head>
    <title>
       dash.php
    </title>
  </head>
  <body>
    <?php
    include('../dbcon.php');
    if(isset($_POST['submit'])){
       echo('divesh');
       // print_r($_POST);
    }  
     ?>
    <form action="dash.php" method="post" id="msform">
      <!-- form fields and submit button -->
    </form>
  </body>

【讨论】:

  • @diveshjain 会发生什么?黑屏?您的 php 日志中有任何错误消息或任何内容吗?
  • 没有错误,只是提交按钮“if”条件本身没有执行。在提交 if 条件下不执行任何操作。我猜从 html 表单获取数据存在一些问题。
猜你喜欢
  • 1970-01-01
  • 2020-01-08
  • 1970-01-01
  • 2019-03-10
  • 2013-04-26
  • 1970-01-01
  • 1970-01-01
  • 2019-01-31
  • 2018-10-03
相关资源
最近更新 更多