我有一个登录表单(index.php),允许学生访问他们的门户网站,学生'然后检查注册号和密码是否插入(login.php)并进入类(StudentLogin.php),如果所有凭据都与数据库中的凭据匹配,则允许学生访问其门户。在输入正确的凭据后,该流程不会继续执行stud_page.php .....我会感谢您对此事的任何帮助,我不了解正在发生的事情。
下面是index.php:
<?php
require("../admin/database.php");
require("../class/StudentLogin.php");
if(isset($_POST['submit'])){
$regnum = trim($_POST['regnumber']);
$password = trim($_POST['password']);
$loginStud = new StudentLogin($reg_num, $password);
$rtnlogin = $loginStud->Studlogin();
}
$conn->close();
?>
Then the StudentLogin class is:
<?php
class StudentLogin
{
private $_regnumber;
private $_password;
public function __construct($c_reg_num, $c_password){
$this->_regnumber = $c_reg_num;
$this->_password = $c_password;
}
public function StudLogin(){
global $conn;
// starting session
session_start();
// valiidate errors
$error_msg_array = array();
// error msg
$error_msg = FALSE;
if($this->_reg_num == ""){
$error_msg_array[] = "Please input your Registration Number";
$error_msg = TRUE;
}
if($this->_password == ""){
$error_msg_array[] = "Please input your password";
$error_msg = TRUE;
}
if($error_msg){
$_SESSION['ERROR_MSG_ARR'] = $error_msg_array;
header("location: http://localhost/project/index.php");
exit();
}
$sql = "SELECT * FROM students WHERE regnumber ='$reg_num' AND password ='$password' LIMIT 1";
if(!$stmt = $conn->prepare($sql)){
echo $stmt->error;
} else {
$stmt->bind_param("ss", $this->_reg_num, $this->_password);
$stmt->execute();
$result = $stmt->get_result();
}
if($result->num_rows > 0) {
// login successful
$row = $result->fetch_assoc();
// session creation
session_regenerate_id();
$_SESSION['reg_num'] = $row["regnunmber"];
$_SESSION['name'] = $row["name"];
session_write_close();
header("location: http://localhost/project/stud_page.php");
} else {
// Login failed
$error_msg_array[] = "The Registration Number and Password you entered is incorrect.";
$error_msg = TRUE;
if($error_msg) {
$_SESSION['ERROR_MSG_ARR'] = $error_msg_array;
header("location: http://localhost/project/index.php");
exit();
}
$stmt->free_result();
}
$result->free();
return $result;
}
}
?>
&#13;
login.php如下:
students
MySQL数据库,表$sql="INSERT INTO `students`(`name`, `education`, `regnumber`, `nationality`, `gender`, `phone`, `photo`, `branch`,`password`)
VALUES ('$name','$education','$reg_num','$nationality','$gender','$phone','$target_file','$branch','$ency_pass')";
包含以下列:
web:
image: nginx:latest
ports:
- "8080:80"
- "8000:8000"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
- dynamodb:db // <-- Probably unnecessary, requires more testing
php:
build: php/
volumes:
- ./code:/code
links:
- dynamodb // <-- Important
dynamodb:
build: dynamodb/
expose:
- 8000
答案 0 :(得分:-2)
您在login.php上有验证,在发送表单之前未加载。 如果你能,我会建议你使用dibi,因为这与数据库的工作不正确,如果你打算在生产中使用它会导致一些问题 https://dibiphp.com/en/