我必须通过表单发送值的问题,看起来该页面没有收到$ sender值。
<script type="text/javascript"> $("button[name='Security']").click(function(){
$("#placeholder").html(<?php $sender=basename($_SERVER[PHP_SELF]); ?>
"
<form class='form-horizontal' method='post' action='changePassword.php'>
<div class='form-group'>
<label for='username' class='col-sm-9 text-center' control-label><span class='label label-danger'><i class='fa fa-eye'></i> Change Password </span> </label>
</div> <!-- col-sm-9 --> <!-- form-group -->
<div class='form-group'>
<label style='margin:5px' for='currentpassword' class='col-sm-4 text-center' control-label><span class='label label-info'><i class='fa fa-eye'></i> Current Password </span></label>
<input style='margin:5px' class='col-sm-5' name='currentpassword' class='form-control' type='password' >
</div>
<div class='form-group'>
<label style='margin:5px' for='password' class='col-sm-4 text-center' control-label><span class='label label-success'><i class='fa fa-eye'></i> New Password </span></label>
<input style='margin:5px' class='col-sm-5' name='password' class='form-control' type='password' >
</div>
<div class='form-group'>
<label style='margin:5px' for='confirmpassword' class='col-sm-4 text-center' control-label><span class='label label-success'><i class='fa fa-eye'></i> Confirm Password </span></label>
<input style='margin:5px' class='col-sm-5' name='confirmpassword' class='form-control' type='password' >
</div>
<div class='form-group>
<input type='hidden' name='sender' value=' <?php echo $sender; ?>' class='form-control' id='sender' >
<button type='submit' class='btn btn-success btn-block'><span class='fa fa-check'></span> Change Password!</button> </div> </form>");
});
</script>
实际上我遇到了最新的麻烦,我已经尝试了很多方法,也把变量分配到value''
,但没有任何作用
答案 0 :(得分:1)
请更改此类代码
<?php
$sender = isset($_SERVER["PHP_SELF"])? "":basename($_SERVER["PHP_SELF"]);
?>
<script type="text/javascript">
$("document").ready(function(){
$("button[name=Security]").click(function(){
$("#placeholder").html("<form class='form-horizontal' method='post' action='changePassword.php'><div class='form-group'><label for='username' class='col-sm-9 text-center' control-label><span class='label label-danger'><i class='fa fa-eye'></i> Change Password </span> </label></div> <!-- col-sm-9 --> <!-- form-group --> <div class='form-group'><label style='margin:5px' for='currentpassword' class='col-sm-4 text-center' control-label><span class='label label-info'><i class='fa fa-eye'></i> Current Password </span></label> <input style='margin:5px' class='col-sm-5' name='currentpassword' class='form-control' type='password' ></div><div class='form-group'><label style='margin:5px' for='password' class='col-sm-4 text-center' control-label><span class='label label-success'><i class='fa fa-eye'></i> New Password </span></label><input style='margin:5px' class='col-sm-5' name='password' class='form-control' type='password' ></div><div class='form-group'><label style='margin:5px' for='confirmpassword' class='col-sm-4 text-center' control-label><span class='label label-success'><i class='fa fa-eye'></i> Confirm Password </span></label><input style='margin:5px' class='col-sm-5' name='confirmpassword' class='form-control' type='password' ></div><div class='form-group><input type='hidden' name='sender' value=' <?php echo $sender; ?>' class='form-control' id='sender' ><button type='submit' class='btn btn-success btn-block'><span class='fa fa-check'></span> Change Password!</button> </div> </form>");
});
});
</script>
答案 1 :(得分:0)
实际上,我发现我忘记了'
<div class='form-group>