Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.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 通过特定按钮提交表单_Php - Fatal编程技术网

Php 通过特定按钮提交表单

Php 通过特定按钮提交表单,php,Php,这是我的表格: <form method= "post" action= "edit.php"> <div class="panel-body"> <div class="row"> <div class="col-md-3 col-lg-3 " id= "show"> <img alt="User Pic" src="http://babyinfoforyou.com/wp-content/uploa

这是我的表格:

 <form method= "post" action= "edit.php">
    <div class="panel-body">
      <div class="row">

        <div class="col-md-3 col-lg-3 " id= "show"> <img alt="User Pic" src="http://babyinfoforyou.com/wp-content/uploads/2014/10/avatar-300x300.png" class="img-circle img-responsive">
        <a data-original-title="Upload Image" data-toggle="tooltip" type="button" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-edit"></i></a>
         </div>
        <div class=" col-md-9 col-lg-9 "> 
          <table class="table table-user-information">
            <tbody>
              <tr>
                <td>Name:</td>
                <td><span id= "keep"><?php echo $firstname;  ?></span><input id= "change" value= "<?php echo $firstname;  ?>" style= "display:none;" name="name"></td> 
              </tr>
              <tr>
                <td>Date of Birth</td>
                <td><span id= "keep1"><?php echo $birthday; ?></span><input id= "change1" value= "<?php echo $birthday; ?>" style= "display:none;" name="bday"></td>
              </tr>

                 <tr>
                     <tr>
                <td>Gender</td>
                <td><span id= "keep2"><?php echo $gender; ?></span><input id= "change2" value= "<?php echo $gender; ?>" style= "display:none;" name="gen"></td>
              </tr>
                <tr>
                <td>Country</td>
                <td><span id= "keep3">US</span><input id= "change3" value= "US" style= "display:none;" name="country"></td>
              </tr>
              <tr>
                <td>Email</td>
                <td><span id= "keep4"><a href="mailto:info@support.com"><?php echo $email; ?></a></span><input id= "change4" value= "<?php echo $email; ?>" style= "display:none;" name="mail"></td>
              </tr>

            </tbody>
          </table>
        </div>
      </div>
    </div>
         <div class="panel-footer">
                <a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
                <span class="pull-right">
                    <a href="#" data-original-title="Edit this user" data-toggle="tooltip" type="button" class="btn btn-sm btn-warning" onclick = 'showMe()'><i class="glyphicon glyphicon-edit"></i></a>
                    <a data-original-title="Save this user" data-toggle="tooltip" class="btn btn-sm btn-success" type="submit"><i class="glyphicon glyphicon-saved"></i></a>

                </span>
            </div>
    </form>


关于表格提交:

  • 如果HTML按钮是
    type=“submit”
    或没有
    type
    属性(默认为
    submit
    ),它将提交其父级
    表单

  • HTML按钮不会提交其父级
    表单
    ,如果是
    type=“button”

  • 因为你似乎坚持使用
    。但是,如果没有理由不使用
    标记,则不建议使用此解决方案,这是一种相当糟糕的做法,因为JavaScript不适用于所有浏览器,默认情况下在其他浏览器中禁用,并且用户始终可以禁用,在所有情况下都会导致表单无效
关于你剩下的问题:

  • 没有PHP,很难了解您的情况

请在表单中添加提交按钮

<input type="submit" name="submit-btn" class="btn btn-primary">

您需要添加提交按钮

<button type="submit"  class="btn >SAVE</button>

为您的
表单提供
id

<form id="myform" method= "post" action= "edit.php">
现在你的锚定标签看起来像

<a onclick="document.getElementById('myform').submit();" 
   data-original-title="Save this user" data-toggle="tooltip" 
   class="btn btn-sm btn-success"><i class="glyphicon glyphicon-saved">
  </i></a> 


对于第一个问题,您需要javascript,而不是php。第二,我不打算帮你,因为你也需要付出一些努力。当没有php来回答这个问题时,它会同时让问题变得“不清楚”和“太宽泛”。那么我该怎么办呢?难道没有其他简单的方法吗@HallurI现在不需要php,我只想让save按钮成为编辑的按钮。php…你需要ajax。我的类型是type=“submit”,但它不起作用,我是否将它插入了错误的区域?你有一个
标记,它是
type=“submit”
。您需要一个
元素,它是
type=“submit”
。如果你想使用
标签提交,你需要使用JavaScript。如果我只是想改变我的按钮的样子?更新你的CSS“开箱即用”表单提交仅适用于
元素。如果您坚持使用
标记,则需要使用JavaScript手动执行。我的建议是:您需要添加一个按钮元素()。你有一个链接(),我也想要它看起来像这样,我应该如何使这个链接转到edit.php
<a onclick="document.getElementById('myform').submit();" 
   data-original-title="Save this user" data-toggle="tooltip" 
   class="btn btn-sm btn-success"><i class="glyphicon glyphicon-saved">
  </i></a>