我有一個登錄表單:
<!--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="[email protected]">
<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 時,如果我對輸入欄位執行與我相同的 POST 值,它會顯示 array(),即使表單填充了一些值,我也會得到 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 變數是具有檢查服務器端輸入值的所有函式的類,如果輸入值以某種方式為空,則用戶將收到輸入值為空的訊息,但此訊息不會出現. 當我單擊登錄提交按鈕時,我被帶到空的 login.inc.php 頁面,但沒有任何反應。
uj5u.com熱心網友回復:
簡單地說,我找不到任何login-submit作為name屬性的東西。也許檢查是否isset($_POST["password"])或“電子郵件”或您的表格中的任何內容。
因為 nologin-submit在您的形式中,所以永遠不會滿足 if 條件。
nameproperty 是發送過來的東西 not id。我看到你提出的問題。您需要login-從 $_POST 方法中洗掉前綴:。您的name屬性只有:密碼、電子郵件、提交等。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/468027.html
