我的 POST 表单没有传递数据 我没有收到任何错误消息,我只是在没有处理数据的情况下被重定向到下一页
My POST form is not passing data I get no error message and I am just redirected to the next page without the data being processed
我有一个登录表单:
<!--SIGNUP = modal_form.php-->
<!--Modal start-->
<div class="modal fade" id="enroll" tabindex="-1" aria-labelledby="enrollLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="enrollLabel">User signup</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead">Fill out this form we will get back to you</p>
<!-- Form -->
<form id="signup-form" class="form" method="POST" action="./includes/signup.inc.php">
<?php
$fullUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($fullUrl, "error=empty_input") == true) {
echo "<div class='alert alert-danger alert-dismissible fade show' role='alert'>
<strong>Holy guacamole!</strong> You should fill in on some of those fields below.
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
</div>";
.
.
.
.
.
<strong>Success!</strong> Success you signed up.
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
</div>";
} else {
unset($_SESSION['error1']);
}
?>
<div class="mb-3 input-control">
<label for="full-name">Full name\User name</label><br>
<p>*You can only have on user name per e-mail account</p>
<input type="text" class="form-control" id="full-name" name="full-name"
placeholder="John Smith">
<small class="message" id="message-full-name"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email"
placeholder="JohnSmith@gmail.com">
<small class="message" id="message-email"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password"
placeholder="Password">
<small class="message" id="message-password"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="pwdRepeat">Password repeat</label>
<input type="password" class="form-control" id="pwdRepeat" name="pwdRepeat"
placeholder="Retype Password">
<small class="message" id="message-pwdRepeat"></small>
<br>
</div>
<a href="./includes/reset-password-form.php">Forgot your password?</a>
<div class="modal-footer">
<button type="reset" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" id="login-submit" class="btn btn-primary" name="submit">Register now</button>
</div>
<script src="./js/signup_error_handler.js"></script>
</form>
</div>
</div>
</div>
</div>
出于某种原因,它没有向该页面发送任何数据 login.inc.php 它打开该页面但不执行任何操作。当我 var_dump() POST 它显示 array() 如果我对输入字段执行与我相同的 POST 值我得到 null 即使表单填充了一些值。
这是数据发送到的页面:
<?php
if (isset($_POST['login-submit'])) {
//Uzimamo podatke
$email = $_POST["login-email"];
$password = $_POST["login-password"];
//Instanciranje klase SignupContr
include "../classes/dbh.classes.php";
include "../classes/login.classes.php";
include "../classes/login-contr.classes.php";
$signup = new LoginContr($email, $password);
//Running error handlers and using signup
$signup->loginUser();
//Povratak na glavnu stranu
header("location: ../index.php?error=none");
}
$signup 变量是 class,它具有检查服务器端输入值的所有功能,如果输入值以某种方式为空,则用户将收到一条消息,指出输入值是空的,但不会出现此消息。当我点击登录提交按钮时,我被带到空的 login.inc.php 页面,但没有任何反应。
简单地说,我找不到任何带有 login-submit
作为 name
属性 的东西。
也许检查 isset($_POST["password"])
或“电子邮件”或您表格中的任何内容。
因为您的表单中没有 login-submit
,所以永远不会满足 if 条件。
name
属性 是发送过来的东西而不是 id
。我看到你提出的问题。您需要从 $_POST 方法中删除前缀:login-
。您的 name
属性只有:密码、电子邮件、提交等
我有一个登录表单:
<!--SIGNUP = modal_form.php-->
<!--Modal start-->
<div class="modal fade" id="enroll" tabindex="-1" aria-labelledby="enrollLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="enrollLabel">User signup</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="lead">Fill out this form we will get back to you</p>
<!-- Form -->
<form id="signup-form" class="form" method="POST" action="./includes/signup.inc.php">
<?php
$fullUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($fullUrl, "error=empty_input") == true) {
echo "<div class='alert alert-danger alert-dismissible fade show' role='alert'>
<strong>Holy guacamole!</strong> You should fill in on some of those fields below.
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
</div>";
.
.
.
.
.
<strong>Success!</strong> Success you signed up.
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
</div>";
} else {
unset($_SESSION['error1']);
}
?>
<div class="mb-3 input-control">
<label for="full-name">Full name\User name</label><br>
<p>*You can only have on user name per e-mail account</p>
<input type="text" class="form-control" id="full-name" name="full-name"
placeholder="John Smith">
<small class="message" id="message-full-name"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email"
placeholder="JohnSmith@gmail.com">
<small class="message" id="message-email"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password"
placeholder="Password">
<small class="message" id="message-password"></small>
<br>
</div>
<div class="mb-3 input-control">
<label for="pwdRepeat">Password repeat</label>
<input type="password" class="form-control" id="pwdRepeat" name="pwdRepeat"
placeholder="Retype Password">
<small class="message" id="message-pwdRepeat"></small>
<br>
</div>
<a href="./includes/reset-password-form.php">Forgot your password?</a>
<div class="modal-footer">
<button type="reset" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" id="login-submit" class="btn btn-primary" name="submit">Register now</button>
</div>
<script src="./js/signup_error_handler.js"></script>
</form>
</div>
</div>
</div>
</div>
出于某种原因,它没有向该页面发送任何数据 login.inc.php 它打开该页面但不执行任何操作。当我 var_dump() POST 它显示 array() 如果我对输入字段执行与我相同的 POST 值我得到 null 即使表单填充了一些值。
这是数据发送到的页面:
<?php
if (isset($_POST['login-submit'])) {
//Uzimamo podatke
$email = $_POST["login-email"];
$password = $_POST["login-password"];
//Instanciranje klase SignupContr
include "../classes/dbh.classes.php";
include "../classes/login.classes.php";
include "../classes/login-contr.classes.php";
$signup = new LoginContr($email, $password);
//Running error handlers and using signup
$signup->loginUser();
//Povratak na glavnu stranu
header("location: ../index.php?error=none");
}
$signup 变量是 class,它具有检查服务器端输入值的所有功能,如果输入值以某种方式为空,则用户将收到一条消息,指出输入值是空的,但不会出现此消息。当我点击登录提交按钮时,我被带到空的 login.inc.php 页面,但没有任何反应。
简单地说,我找不到任何带有 login-submit
作为 name
属性 的东西。
也许检查 isset($_POST["password"])
或“电子邮件”或您表格中的任何内容。
因为您的表单中没有 login-submit
,所以永远不会满足 if 条件。
name
属性 是发送过来的东西而不是 id
。我看到你提出的问题。您需要从 $_POST 方法中删除前缀:login-
。您的 name
属性只有:密码、电子邮件、提交等