如何在在线web服务器中相互链接php/html页面?mysqli的附加问题
我正在尝试为我的个人简历制作一个简单的网页,任何想要查看我个人简历的人都可以注册,然后在首页用用户名和密码登录(是的,这很愚蠢,但这只是为了一个简单的项目,我不打算这样做)。问题是,当我将这些HTML和PHP文件上传到在线服务器时,这些页面不工作,或者注册了一个登录名,即使它应该可以工作 我总共有8个文件处理登录系统和主页。 第一个文件是头文件,其中包含主页的HTML代码和几行处理会话启动登录的PHP代码,以及负责在登录会话中维护用户的if-else语句。这是非常混乱的,我的HTML编码是可怕的,所以有很多多余的代码行的按钮和列表,我不使用,但计划使用一旦我想一切 第二个文件是index.php。该文件在开头和结尾包含两行PHP代码,需要“header.PHP”和“footer.PHP”。介于两者之间的是代码,它基本上会向用户提供一条消息,告诉用户他们是登录还是注销 第三个文件是footer.php。这就是它,一个简单的页脚文件,带有结尾页脚和HTML标记,仅此而已 第四个文件是signup.php。同样,与index.php一样,它在开头和结尾都包含代码行“require='header.php'”和“require='footer.php'”。中间是一组if-elseif-else代码,用于处理用户是否在字段中输入字符以及出错时产生的错误 最后四个文件是放在根目录中“看不见”文件夹中并处理后台任务的文件 第五个文件是“loginunseed.php”。这个文件处理登录信息 第六个文件是“signupunseen.php”。这个文件处理注册信息并检查数据库中是否有重复项 第七个文件是“logoutunseen.php”。这是一个小文件,它通过几个session_x()将用户从会话中“注销”;声明 第八个文件是“databasehandlerunseen.php”。该文件执行登录到存储用户信息的主SQL数据库的操作。当我在本地使用时,我会更改用户名、密码和数据库以在本地服务器上使用,但当我将其上载到具有不同密码、用户名和数据库的联机服务器时,我会确保更改变量 最后,在MySQL中,有一个数据库,我正在使用一个名为“users”的表,其中的条目是“idUsers int(11)PRIMARY_KEY AUTO_INCREMENT NOT NULL”,“usernameUsers TINYTEXT NOT NULL”,“emailUsers TINYTEXT NOT NULL”,“passwordUsers LONGTEXT NOT NULL” 我使用CSS文件来设计网站,但这并不重要 ****************header.php***************如何在在线web服务器中相互链接php/html页面?mysqli的附加问题,php,html,Php,Html,我正在尝试为我的个人简历制作一个简单的网页,任何想要查看我个人简历的人都可以注册,然后在首页用用户名和密码登录(是的,这很愚蠢,但这只是为了一个简单的项目,我不打算这样做)。问题是,当我将这些HTML和PHP文件上传到在线服务器时,这些页面不工作,或者注册了一个登录名,即使它应该可以工作 我总共有8个文件处理登录系统和主页。 第一个文件是头文件,其中包含主页的HTML代码和几行处理会话启动登录的PHP代码,以及负责在登录会话中维护用户的if-else语句。这是非常混乱的,我的HTML编码是可怕的
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Read about me!</title>
<link href="sitelook.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<nav>
<div class="row">
<div class="logo">
<img src="logo1.png">
</div>
<ul class="main-nav">
<li class="active"><a href=""> Sign in </a></li>
<li><a href=""> About </a></li>
<li><a href=""> FAQ </a></li>
<li><a href=""> Log Out </a></li>
</ul>
</div>
<div class ="header-login">
<?php
if (isset($_SESSION['userID'])){
echo '<form action="unseen/logoutunseen.php" method="post">
<button type="submit" name="logout-submit">Logout</button>
</form>';
} else {
echo '<form action="unseen/loginunseen.php" method="post">
<input type="text" name="mailuid" placeholder="username">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="login-submit">Login</button>
</form>';
}
?>
<a href="signup.php" class="header-signup">Sign up</a>
</div>
<div class="hero">
<h1>Want to read my bio? Login!</h1>
<div class="button">
<a href="" class="btn btn-one"> Log in</a>
</div>
</div>
</nav>
</header>
<?php
require "header.php";
?>
<main>
<div class="wrapper-main">
<section class="section-default">
<?php
if (isset($_SESSION['userID'])){
echo '<p class="login-status">Logged in!</p>';
} else {
echo '<p class="logout-status">Logged out!</p>';
}
?>
</section>
</div>
</main>
<?php
require "footer.php";
?>
?php
require "header.php";
?>
//in form class, check unseen/signup.php
<main>
<div class="wrapper-main">
<section class="section-default">
<h1>Sign up to read my bio!</h1>
<?php
if (isset($_GET['error'])){
if($_GET['error'] == "emptyfields"){
echo '<p class="signuperror">Fill in the fields</p>';
} elseif ($_GET['error'] == "invaliduidmail"){
echo '<p class="signuperror">Invalid username and email</p>';
} elseif ($_GET['error'] == "invaliduid"){
echo '<p class="signuperror">Invalid username</p>';
} elseif ($_GET['error'] == "invalidmail"){
echo '<p class="signuperror">Invalid email</p>';
} elseif ($_GET['error'] == "usertaken"){
echo '<p class="signuperror">Username taken</p>';
}
} elseif ($_GET['success'] == "signup"){ //success=signup
echo '<p class="signupsuccess">You are signed!</p>';
}
?>
<form class="form-signup" action="unseen/signupunseen.php" method="post">
<input type="text" name="uid" placeholder="username">
<input type="text" name="mail" placeholder="email">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="signup-submit">Signup</button>
</form>
</section>
</div>
</main>
<?php
require "footer.php";
?>
<footer>
</footer>
</body>
</html>
<?php
if (isset($_POST['login-submit'])) { //in require 'databasehandlerunseen.php check if path file is correct
require 'unseen/databasehandlerunseen.php';
$mailuserid = $_POST['mailuid'];
$password = $_POST['pwd'];
if (empty($mailuserid) || empty($password)) {
header("Location: ../index.php?error=emptyfields");
exit();
} else { //checks if the user's password inputted is correct or in the database
$sql = "SELECT * FROM users WHERE usernameUsers=? or emailUsers=?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../index.php?error=sqlerror");
exit();
} else{
mysqli_stmt_bind_param($stmt, "ss", $mailuserid, $mailuserid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)){
$passCheck = password_verify($password, $row['passwordUsers']);
if ($passCheck == FALSE){
header("Location: ../index.php?error=wrongpassword");
exit();
} elseif ($passCheck == TRUE){
session_start();
$_SESSION['userID'] = $row['idUsers'];
$_SESSION['userUserID'] = $row['usernameUsers'];
header("Location: ../index.php?login=successpass");
exit();
}
else {
header("Location: ../index.php?error=wrongpassword");
exit();
}
} else {
header("Location: ../index.php?error=nouser");
exit();
}
}
}
}
else {
header("Location: ../signup.php");
exit();
}
?>
<?php
if (isset($_POST['signup-submit'])) {
require 'unseen/databasehandlerunseen.php';
//now to fetch information from form. Use 'uid', 'mail', 'pwd' from signup.php
$username = $_POST['uid'];
$email = $_POST['mail'];
$password = $_POST['pwd'];
//error handlers to check if user inputted correct info
//check if fields are empty
if (empty($username) || empty($email) || empty($password)) {
header("Location: ../signup.php?error=emptyfields&uid=" . $username . "&email=" . $email);
exit();
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL) && !preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invalidmail&uid");
exit();
} //checks for invalid email
elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?error=invalidmail&uid=".$username);
exit();
} elseif (!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invaliduid&mail=".$email);
exit();
} // This else statement checks if user signs in with a username already taken
else {
// MySQL query statement, make sure entries are correct
// Must use prepared statements for extra layer of security
$sql = "SELECT usernameUsers FROM users WHERE usernameUsers=?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $username);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$resultCheck = mysqli_stmt_num_rows($stmt);
if ($resultCheck > 0) {
header("Location: ../signup.php?error=usertaken&mail=" . $email);
exit();
} else {
$sql = "INSERT INTO users (usernameUsers,emailUsers, passwordUsers) VALUES(?,?,?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else { // creating hash of passwords inputted for security. PASSWORD_DEFAULT IS SECURE AND UPDATED
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "sss", $username, $email, $password);
mysqli_stmt_execute($stmt);
header("Location: ../signup.php?success=signup");
exit();
}
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
else {
header("Location: ../signup.php");
exit();
}
<?php
//logs you out
session_start();
session_unset();
session_destroy();
header("Location: ../index.php");
?>
<?php
//these variables need to be changed before uploaded to online server
$servername = "localhost";
$dBUsername = "root";
$dBPassword = "";
//dBName is name of the database in mysql. If using locally, it's loginsys. Online database, it's bremy_project
$dBName = "NAME OF DATABASE HERE";
$conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
if(!$conn){
die("Connection failed: ".mysqli_connect_error());
}
?>
了解我!
想看我的简历吗?登录!
****************index.php*****************
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Read about me!</title>
<link href="sitelook.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<nav>
<div class="row">
<div class="logo">
<img src="logo1.png">
</div>
<ul class="main-nav">
<li class="active"><a href=""> Sign in </a></li>
<li><a href=""> About </a></li>
<li><a href=""> FAQ </a></li>
<li><a href=""> Log Out </a></li>
</ul>
</div>
<div class ="header-login">
<?php
if (isset($_SESSION['userID'])){
echo '<form action="unseen/logoutunseen.php" method="post">
<button type="submit" name="logout-submit">Logout</button>
</form>';
} else {
echo '<form action="unseen/loginunseen.php" method="post">
<input type="text" name="mailuid" placeholder="username">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="login-submit">Login</button>
</form>';
}
?>
<a href="signup.php" class="header-signup">Sign up</a>
</div>
<div class="hero">
<h1>Want to read my bio? Login!</h1>
<div class="button">
<a href="" class="btn btn-one"> Log in</a>
</div>
</div>
</nav>
</header>
<?php
require "header.php";
?>
<main>
<div class="wrapper-main">
<section class="section-default">
<?php
if (isset($_SESSION['userID'])){
echo '<p class="login-status">Logged in!</p>';
} else {
echo '<p class="logout-status">Logged out!</p>';
}
?>
</section>
</div>
</main>
<?php
require "footer.php";
?>
?php
require "header.php";
?>
//in form class, check unseen/signup.php
<main>
<div class="wrapper-main">
<section class="section-default">
<h1>Sign up to read my bio!</h1>
<?php
if (isset($_GET['error'])){
if($_GET['error'] == "emptyfields"){
echo '<p class="signuperror">Fill in the fields</p>';
} elseif ($_GET['error'] == "invaliduidmail"){
echo '<p class="signuperror">Invalid username and email</p>';
} elseif ($_GET['error'] == "invaliduid"){
echo '<p class="signuperror">Invalid username</p>';
} elseif ($_GET['error'] == "invalidmail"){
echo '<p class="signuperror">Invalid email</p>';
} elseif ($_GET['error'] == "usertaken"){
echo '<p class="signuperror">Username taken</p>';
}
} elseif ($_GET['success'] == "signup"){ //success=signup
echo '<p class="signupsuccess">You are signed!</p>';
}
?>
<form class="form-signup" action="unseen/signupunseen.php" method="post">
<input type="text" name="uid" placeholder="username">
<input type="text" name="mail" placeholder="email">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="signup-submit">Signup</button>
</form>
</section>
</div>
</main>
<?php
require "footer.php";
?>
<footer>
</footer>
</body>
</html>
<?php
if (isset($_POST['login-submit'])) { //in require 'databasehandlerunseen.php check if path file is correct
require 'unseen/databasehandlerunseen.php';
$mailuserid = $_POST['mailuid'];
$password = $_POST['pwd'];
if (empty($mailuserid) || empty($password)) {
header("Location: ../index.php?error=emptyfields");
exit();
} else { //checks if the user's password inputted is correct or in the database
$sql = "SELECT * FROM users WHERE usernameUsers=? or emailUsers=?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../index.php?error=sqlerror");
exit();
} else{
mysqli_stmt_bind_param($stmt, "ss", $mailuserid, $mailuserid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)){
$passCheck = password_verify($password, $row['passwordUsers']);
if ($passCheck == FALSE){
header("Location: ../index.php?error=wrongpassword");
exit();
} elseif ($passCheck == TRUE){
session_start();
$_SESSION['userID'] = $row['idUsers'];
$_SESSION['userUserID'] = $row['usernameUsers'];
header("Location: ../index.php?login=successpass");
exit();
}
else {
header("Location: ../index.php?error=wrongpassword");
exit();
}
} else {
header("Location: ../index.php?error=nouser");
exit();
}
}
}
}
else {
header("Location: ../signup.php");
exit();
}
?>
<?php
if (isset($_POST['signup-submit'])) {
require 'unseen/databasehandlerunseen.php';
//now to fetch information from form. Use 'uid', 'mail', 'pwd' from signup.php
$username = $_POST['uid'];
$email = $_POST['mail'];
$password = $_POST['pwd'];
//error handlers to check if user inputted correct info
//check if fields are empty
if (empty($username) || empty($email) || empty($password)) {
header("Location: ../signup.php?error=emptyfields&uid=" . $username . "&email=" . $email);
exit();
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL) && !preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invalidmail&uid");
exit();
} //checks for invalid email
elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?error=invalidmail&uid=".$username);
exit();
} elseif (!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invaliduid&mail=".$email);
exit();
} // This else statement checks if user signs in with a username already taken
else {
// MySQL query statement, make sure entries are correct
// Must use prepared statements for extra layer of security
$sql = "SELECT usernameUsers FROM users WHERE usernameUsers=?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $username);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$resultCheck = mysqli_stmt_num_rows($stmt);
if ($resultCheck > 0) {
header("Location: ../signup.php?error=usertaken&mail=" . $email);
exit();
} else {
$sql = "INSERT INTO users (usernameUsers,emailUsers, passwordUsers) VALUES(?,?,?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else { // creating hash of passwords inputted for security. PASSWORD_DEFAULT IS SECURE AND UPDATED
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "sss", $username, $email, $password);
mysqli_stmt_execute($stmt);
header("Location: ../signup.php?success=signup");
exit();
}
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
else {
header("Location: ../signup.php");
exit();
}
<?php
//logs you out
session_start();
session_unset();
session_destroy();
header("Location: ../index.php");
?>
<?php
//these variables need to be changed before uploaded to online server
$servername = "localhost";
$dBUsername = "root";
$dBPassword = "";
//dBName is name of the database in mysql. If using locally, it's loginsys. Online database, it's bremy_project
$dBName = "NAME OF DATABASE HERE";
$conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
if(!$conn){
die("Connection failed: ".mysqli_connect_error());
}
?>
****************signup.php*****************
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Read about me!</title>
<link href="sitelook.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<nav>
<div class="row">
<div class="logo">
<img src="logo1.png">
</div>
<ul class="main-nav">
<li class="active"><a href=""> Sign in </a></li>
<li><a href=""> About </a></li>
<li><a href=""> FAQ </a></li>
<li><a href=""> Log Out </a></li>
</ul>
</div>
<div class ="header-login">
<?php
if (isset($_SESSION['userID'])){
echo '<form action="unseen/logoutunseen.php" method="post">
<button type="submit" name="logout-submit">Logout</button>
</form>';
} else {
echo '<form action="unseen/loginunseen.php" method="post">
<input type="text" name="mailuid" placeholder="username">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="login-submit">Login</button>
</form>';
}
?>
<a href="signup.php" class="header-signup">Sign up</a>
</div>
<div class="hero">
<h1>Want to read my bio? Login!</h1>
<div class="button">
<a href="" class="btn btn-one"> Log in</a>
</div>
</div>
</nav>
</header>
<?php
require "header.php";
?>
<main>
<div class="wrapper-main">
<section class="section-default">
<?php
if (isset($_SESSION['userID'])){
echo '<p class="login-status">Logged in!</p>';
} else {
echo '<p class="logout-status">Logged out!</p>';
}
?>
</section>
</div>
</main>
<?php
require "footer.php";
?>
?php
require "header.php";
?>
//in form class, check unseen/signup.php
<main>
<div class="wrapper-main">
<section class="section-default">
<h1>Sign up to read my bio!</h1>
<?php
if (isset($_GET['error'])){
if($_GET['error'] == "emptyfields"){
echo '<p class="signuperror">Fill in the fields</p>';
} elseif ($_GET['error'] == "invaliduidmail"){
echo '<p class="signuperror">Invalid username and email</p>';
} elseif ($_GET['error'] == "invaliduid"){
echo '<p class="signuperror">Invalid username</p>';
} elseif ($_GET['error'] == "invalidmail"){
echo '<p class="signuperror">Invalid email</p>';
} elseif ($_GET['error'] == "usertaken"){
echo '<p class="signuperror">Username taken</p>';
}
} elseif ($_GET['success'] == "signup"){ //success=signup
echo '<p class="signupsuccess">You are signed!</p>';
}
?>
<form class="form-signup" action="unseen/signupunseen.php" method="post">
<input type="text" name="uid" placeholder="username">
<input type="text" name="mail" placeholder="email">
<input type="password" name="pwd" placeholder="password">
<button type="submit" name="signup-submit">Signup</button>
</form>
</section>
</div>
</main>
<?php
require "footer.php";
?>
<footer>
</footer>
</body>
</html>
<?php
if (isset($_POST['login-submit'])) { //in require 'databasehandlerunseen.php check if path file is correct
require 'unseen/databasehandlerunseen.php';
$mailuserid = $_POST['mailuid'];
$password = $_POST['pwd'];
if (empty($mailuserid) || empty($password)) {
header("Location: ../index.php?error=emptyfields");
exit();
} else { //checks if the user's password inputted is correct or in the database
$sql = "SELECT * FROM users WHERE usernameUsers=? or emailUsers=?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../index.php?error=sqlerror");
exit();
} else{
mysqli_stmt_bind_param($stmt, "ss", $mailuserid, $mailuserid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)){
$passCheck = password_verify($password, $row['passwordUsers']);
if ($passCheck == FALSE){
header("Location: ../index.php?error=wrongpassword");
exit();
} elseif ($passCheck == TRUE){
session_start();
$_SESSION['userID'] = $row['idUsers'];
$_SESSION['userUserID'] = $row['usernameUsers'];
header("Location: ../index.php?login=successpass");
exit();
}
else {
header("Location: ../index.php?error=wrongpassword");
exit();
}
} else {
header("Location: ../index.php?error=nouser");
exit();
}
}
}
}
else {
header("Location: ../signup.php");
exit();
}
?>
<?php
if (isset($_POST['signup-submit'])) {
require 'unseen/databasehandlerunseen.php';
//now to fetch information from form. Use 'uid', 'mail', 'pwd' from signup.php
$username = $_POST['uid'];
$email = $_POST['mail'];
$password = $_POST['pwd'];
//error handlers to check if user inputted correct info
//check if fields are empty
if (empty($username) || empty($email) || empty($password)) {
header("Location: ../signup.php?error=emptyfields&uid=" . $username . "&email=" . $email);
exit();
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL) && !preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invalidmail&uid");
exit();
} //checks for invalid email
elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?error=invalidmail&uid=".$username);
exit();
} elseif (!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("Location: ../signup.php?error=invaliduid&mail=".$email);
exit();
} // This else statement checks if user signs in with a username already taken
else {
// MySQL query statement, make sure entries are correct
// Must use prepared statements for extra layer of security
$sql = "SELECT usernameUsers FROM users WHERE usernameUsers=?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $username);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$resultCheck = mysqli_stmt_num_rows($stmt);
if ($resultCheck > 0) {
header("Location: ../signup.php?error=usertaken&mail=" . $email);
exit();
} else {
$sql = "INSERT INTO users (usernameUsers,emailUsers, passwordUsers) VALUES(?,?,?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else { // creating hash of passwords inputted for security. PASSWORD_DEFAULT IS SECURE AND UPDATED
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "sss", $username, $email, $password);
mysqli_stmt_execute($stmt);
header("Location: ../signup.php?success=signup");
exit();
}
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
else {
header("Location: ../signup.php");
exit();
}
<?php
//logs you out
session_start();
session_unset();
session_destroy();
header("Location: ../index.php");
?>
<?php
//these variables need to be changed before uploaded to online server
$servername = "localhost";
$dBUsername = "root";
$dBPassword = "";
//dBName is name of the database in mysql. If using locally, it's loginsys. Online database, it's bremy_project
$dBName = "NAME OF DATABASE HERE";
$conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
if(!$conn){
die("Connection failed: ".mysqli_connect_error());
}
?>
?php
需要“header.php”;
?>
//在form类中,选中unseen/signup.php
注册阅读我的个人简历!
您应该通过启用php错误报告来调试php代码。
显示所有php错误和警告的最快方法是将以下行添加到php代码文件中:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
将这些行添加到php文件后,您将看到一些错误,并知道为什么您总是停留在主页上这里发生了很多事情。。。请把范围缩小到一个具体问题。首先确保PHP使用简单的phpinfo()
运行。检查你的错误日志。好吧,首先,当我尝试注册或登录时,什么都没有发生。我并没有真正得到一个错误代码,当我尝试注册或输入用户名和密码时所发生的一切只是刷新页面而没有发生任何事情。浏览器会将用户名和密码识别为进入(因为它会给我一条消息说“您想为blah保存此密码吗”),但当我检查数据库和表时,它是空的。现在,我确实有很多无用的按钮,我没有在代码中建立这些按钮,但是用户名、密码和登录按钮应该被定义和使用,但是没有。好吧,所以我用你推荐的那些行浏览了每个文件,我得到了一个错误。对于signup.php,我在第22行收到一条通知,上面写着“Undefined index:success in..。您应该使用来检查是否设置了数组键,是否使用了isset()函数。