表单仅通过按钮提交

时间:2016-12-14 14:34:42

标签: 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/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>

如何只将“保存”按钮转到edit.php而不是其他按钮?现在,当我点击它不会去任何地方,然后在编辑。 php我希望它更新并返回到此页面的更新版本,我只是坚持如何让它去edit.php

1 个答案:

答案 0 :(得分:1)

你的通知告诉你:

$_POST['name'];
$_POST['bday'];
$_POST['gen'];
$mail = $_POST['mail'];

..根本没有设置。您似乎没有通过$_POST数组将这些值传递给您的php脚本。 UPD 1: 您可以选择(1)将表格嵌入<form>或(2)创建一个js / jquery脚本,将脚本的各个输入提交到您的php脚本。