我正在尝试在我的项目上实现一个简单的登录功能,但由于某种原因它没有按预期工作(或根本没有)。
我无法从php表单中获取operator+
属性的数据,因此我可以继续登录。由于某种原因,根本没有获取数据。我是网络开发的新手,所以请帮助。
这是包含表格
的模态name
这是用于登录的php:
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">LOGIN</h4>
</div>
<div class="modal-body">
<p>Please, enter your login details.</p>
</div>
<form method="POST" action="homePage.php">
<div class="row">
<div class="col-xs-7">
<input type="text" name="txtUserEmail" class="form-control modalForm" id="usr" placeholder=" CPR 000000-0000">
</div>
</div>
<div class="row">
<div class="col-xs-7">
<input type="password" class="form-control modalForm" name="txtUserPassword" id="pwd" placeholder="Password">
</div>
</div>
<button type="button" class="btn btn-info modalForm" data-dismiss="modal">Login</button>
</form>
<div class="modal-footer">
</div>
</div>
任何意见都将受到赞赏。
答案 0 :(得分:2)
在按钮标签
中设置名称=“提交”并输入=“提交”<button name="submit" type="submit" class="btn btn-info modalForm" data-dismiss="modal">Login</button>
并设置这样的条件
if(isset($_POST['submit'])){
$arr = array();
foreach ($json_a as $json_r) {
if ($json_r['userName']==$_POST["txtUserEmail"] && $json_r['pass']==$_POST["txtUserPassword"] ) {
file_put_contents("prods.json",$json_r['userName']);
if ($json_r['isAdmin']==1) {
$_SESSION['userEmail'] = $json_r['userName'];
header('location: adminPage.php');
# code...
}else{
$_SESSION['userEmail'] = $json_r['userName'];
header('location: patientPage.php');
}
}
}
}
答案 1 :(得分:2)
试试这个
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">LOGIN</h4>
</div>
<div class="modal-body">
<p>Please, enter your login details.</p>
</div>
<form method="POST" action="homePage.php">
<div class="row">
<div class="col-xs-7">
<input type="text" name="txtUserEmail" class="form-control modalForm" id="usr" placeholder=" CPR 000000-0000">
</div>
</div>
<div class="row">
<div class="col-xs-7">
<input type="password" class="form-control modalForm" name="txtUserPassword" id="pwd" placeholder="Password">
</div>
</div>
<button type="submit" class="btn btn-info modalForm" >Login</button>
</form>
<div class="modal-footer">
</div>