- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有在教程帮助下编写的验证码。代码对我来说看起来是正确的,表单上的提交按钮使用“POST”方法链接到正确的页面。但是,在提交注册信息时,浏览器会打开一个后端页面,显示脚本的某些部分。显然,这并不是要这样做,而是访问所述页面以进行验证并链接回注册页面,并在 url 中嵌入一条成功消息。
这是包含表单的 signup.php 页面:
<!DOCTYPE html>
<html>
<head>
<title>Signup</title>
<link rel="stylesheet" type="text/css" href="signupstyle.css">
</head>
<body>
<div class="signup-wrapper">
<h3>Sign Up</h3>
<form class="signup-form" action="functions/signup.func.php" method="POST">
<ul>
<li>
<input type="text" name="fname" placeholder="First Name">
</li>
<li>
<input type="text" name="lname" placeholder="Last Name">
</li>
<li>
<input type="text" name="username" placeholder="Username">
</li>
<li>
<input type="email" name="email" placeholder="Email">
</li>
<li>
<input type="password" name="password" placeholder="Password">
</li>
<li>
<button>Sign Up</button>
</li>
</ul>
</form>
</div>
<footer>
</footer>
</body>
</html>
它要发布到的页面是后端,这是它的代码:
<? php
if (isset($POST['submit'])) { //ensure that the submit button was pressed to
access the page.
include_once 'dbc.func.php';
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$username = mysqli_real_escape_string($conn, $_POST['username']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
//HANDLING ERRORS
//Checking for empty fields
if (empty($fname) || empty($lname) || empty($username) || empty($email) || ($password)) {
header("Location: .../signup.php?signupfields=empty"); //if any of the above are empty, redirect to signup page.
exit();
}else{
//Checking for invalid input characters
if (!preg_match("/^[a-zA-Z]*$/", $fname) || (!preg_match("/^[a-zA-Z]*$/", $lname)) {
header("Location: .../signup.php?signupfields=invalidchars"); //if any of the above are empty, redirect to signup page.
exit();
}else{
//Checking the email validity
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: .../signup.php?signupfields=invalidemail"); //if any of the above are empty, redirect to signup page.
exit();
}else{
//Checking for username similarity
$sql = "SELECT * FROM users WHERE username = '$username'";
$resulter = mysqli_query($conn, $sql);
$checkResulter = mysqli_num_rows($resulter);
if ($checkResulter > 0) {
header("Location: .../signup.php?signupfields=usernametaken"); //if any of the above are empty, redirect to signup page.
exit();
}else{
//Hashing the inputted password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
//Inserting the inputted user details into the database
$inputer = "INSERT INTO users (fname, lname, username, email, password) VALUES ('$fname', '$lname', '$username', '$email', '$hashedPassword');";
mysqli_query($conn,$inputer);
header("Location: .../signup.php?signupsuccess"); //redirect to signup page.
exit();
}
}
}
}
}else{
header("Location: ../signup.php?badlogin"); //redirect users to the
signup.php page.
exit();
}
看起来一切正常,但它会抛出 signup.func.php 页面,页面上显示以下代码:
0) { header("Location: .../signup.php?signupfields=usernametaken"); //if any of the above are empty, redirect to signup page. exit(); }else{ //Hashing the inputted password $hashedPassword = password_hash($password, PASSWORD_DEFAULT); //Inserting the inputted user details into the database $inputer = "INSERT INTO users (fname, lname, username, email, password) VALUES ('$fname', '$lname', '$username', '$email', '$hashedPassword');"; mysqli_query($conn,$inputer); header("Location: .../signup.php?signupsuccess"); //redirect to signup page. exit(); } } } } }else{ header("Location: ../signup.php?badlogin"); //redirect users to the signup.php page. exit(); }
不出所料,这并不意味着这样做,我已经厌倦了在代码中没有发现任何错误。谁能帮我吗?
编辑:
阅读提供的文章后,我使用了错误处理程序
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
当我再次运行代码时,它给了我这个:
Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\Rizeapp\functions\dbc.func.php on line 10
fatal error :未捕获 mysqli_sql_exception:php_network_getaddresses:getaddrinfo 失败:不知道这样的主机。在 C:\xampp\htdocs\Rizeapp\functions\dbc.func.php:10 堆栈跟踪:#0 C:\xampp\htdocs\Rizeapp\functions\dbc.func.php(10): mysqli_connect('localhost, root ...') #1 C:\xampp\htdocs\Rizeapp\functions\signup.func.php(4): include_once('C:\xampp\htdocs...') #2 {main} 抛出在 C:\xampp\htdocs\Rizeapp\functions\dbc.func.php 第 10 行
如果这是我认为的意思,那就是 XAMPP 服务器详细信息不正确。我会研究解决这个问题,看看代码是否会运行。
编辑 2:当它起作用时,我真的很高兴。上面 EDIT 1 中抛出的第二个错误是由于我所知道的最愚蠢的错误:我这样做了:
$conn = mysqli_connect("$dbServername, $dbUsername, $dbPassword,
$dbName");
取而代之的是:
$conn = mysqli_connect("$dbServername", "$dbUsername", "$dbPassword",
"$dbName");
感谢大家的迅速回复,最终解决了问题。现在,我可以继续全力推进该项目。干杯。
最佳答案
发现的问题:
<? php
. php 文件然后像文本文件一样显示代码。正确:<?php
.!preg_match...
在if
语句是一个错误的字符(
.正确:将被删除。//
开头, 或外面 /* ... */
, 发生错误。$POST['submit']
. HTTP POST 方法的正确全局变量名为 $_POST
.所以,正确的代码是:$_POST['submit']
.<button>Sign Up</button>
,那么你必须给它一个名字(比如 <button name="submit">Sign Up</button>
),以便能够用 if (isset($_POST['submit'])) {...}
来引用它。 ..../abc/xyz.php
.正确:../abc/xyz.php
.if (... || empty($email) || ($password)) {...}
.正确:if (... || empty($email) || empty($password)) {...}
.建议:
signup.php
中, 而不是 signup.func.php
并相应地改变它。表单的 action 属性将为 signup.php
, 或 ""
对于 HTML5,那么。这样您就可以直接(例如现场)向用户显示任何消息,并且在注册处理成功时最后只执行一次重定向(例如到 login.php
页面)。 promise 的替代代码(使用面向对象的 mysqli)
它包括我上面的建议。按原样运行它以对其进行测试。但是首先更改表结构(参见下面的标题使用的表结构),更改connection.php中的数据库凭据(参见标题includes/connection.php 下面)并按照下面代码部分的标题建议创建一个文件系统结构。
要从生产环境(当错误未显示在屏幕上时)切换到开发环境(当所有引发的错误都显示在屏幕上时),只需更改常量 APP_ENV 的值(在 handlers.php 中)从 'prod' 到 'dev' 并返回(参见标题 includes/handlers.php)。然后,为了测试它,将表名“users”重命名为另一个错误的名称,例如。或者将两条sql语句的第一条设置为NULL
: $sql = NULL;
.
<?php
require 'includes/handlers.php';
require 'includes/connection.php';
// Signalize if a new account could be created, or not.
$accountCreated = FALSE;
/*
* ====================================
* Operations upon form submission.
* ====================================
*/
if (isset($_POST['submit'])) {
/*
* ====================================
* Read the posted values.
* ====================================
*/
$firstName = isset($_POST['firstName']) ? $_POST['firstName'] : '';
$lastName = isset($_POST['lastName']) ? $_POST['lastName'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
/*
* ====================================
* Validate all posted values together.
* ====================================
*/
if (empty($firstName) && empty($lastName) && empty($email) && empty($username) && empty($password)) {
$errors[] = 'All values are mandatory. Please provide them.';
}
/*
* ====================================
* Validate each value separately.
* ====================================
*/
if (!isset($errors)) {
// Validate the first name.
if (empty($firstName)) {
$errors[] = 'Please provide a first name.';
} elseif (!preg_match('/^[a-zA-Z]*$/', $firstName)) {
$errors[] = 'The first name contains invalid characters.';
} /* Other validations here using elseif statements */
// Validate the last name.
if (empty($lastName)) {
$errors[] = 'Please provide a last name.';
} elseif (!preg_match('/^[a-zA-Z]*$/', $lastName)) {
$errors[] = 'The last name contains invalid characters.';
} /* Other validations here using elseif statements */
// Validate the email.
if (empty($email)) {
$errors[] = 'Please provide an email address.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'The email address is not in a valid format.';
} /* Other validations here using elseif statements */
// Validate the username.
if (empty($username)) {
$errors[] = 'Please provide a username.';
} /* Other validations here using elseif statements */
// Validate the password.
if (empty($password)) {
$errors[] = 'Please provide a password.';
} /* Other validations here using elseif statements */
}
/*
* ====================================
* Check if user exists. Save if not.
* ====================================
*/
if (!isset($errors)) {
/*
* ====================================
* Check if user already exists.
* ====================================
*/
/*
* The SQL statement to be prepared. Notice the so-called markers,
* e.g. the "?" signs. They will be replaced later with the
* corresponding values when using mysqli_stmt::bind_param.
*
* @link http://php.net/manual/en/mysqli.prepare.php
*/
$sql = 'SELECT COUNT(*)
FROM users
WHERE username = ?';
/*
* Prepare the SQL statement for execution - ONLY ONCE.
*
* @link http://php.net/manual/en/mysqli.prepare.php
*/
$statement = $connection->prepare($sql);
/*
* Bind variables for the parameter markers (?) in the
* SQL statement that was passed to prepare(). The first
* argument of bind_param() is a string that contains one
* or more characters which specify the types for the
* corresponding bind variables.
*
* @link http://php.net/manual/en/mysqli-stmt.bind-param.php
*/
$statement->bind_param('s', $username);
/*
* Execute the prepared SQL statement.
* When executed any parameter markers which exist will
* automatically be replaced with the appropriate data.
*
* @link http://php.net/manual/en/mysqli-stmt.execute.php
*/
$statement->execute();
/*
* Transfer the result set resulted from executing the prepared statement.
* E.g. store, e.g. buffer the result set into the (same) prepared statement.
*
* @link http://php.net/manual/en/mysqli-stmt.store-result.php
* @link https://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result
*/
$statement->store_result();
/*
* Bind the result set columns to corresponding variables.
* E.g. these variables will hold the column values after fetching.
*
* @link http://php.net/manual/en/mysqli-stmt.bind-result.php
*/
$statement->bind_result($numberOfFoundUsers);
/*
* Fetch the results from the result set (of the prepared statement) into the bound variables.
*
* @link http://php.net/manual/en/mysqli-stmt.fetch.php
*/
$statement->fetch();
/*
* Free the stored result memory associated with the statement,
* which was allocated by mysqli_stmt::store_result.
*
* @link http://php.net/manual/en/mysqli-result.free.php
*/
$statement->free_result();
/*
* Close the prepared statement. It also deallocates the statement handle.
* If the statement has pending or unread results, it cancels them
* so that the next query can be executed.
*
* @link http://php.net/manual/en/mysqli-stmt.close.php
*/
$statement->close();
if ($numberOfFoundUsers > 0) {
$errors[] = 'The given username already exists. Please choose another one.';
} else {
/*
* ====================================
* Save a new user account.
* ====================================
*/
// Create a password hash.
$passwordHash = password_hash($password, PASSWORD_BCRYPT);
$sql = 'INSERT INTO users (
first_name,
last_name,
email,
username,
password
) VALUES (
?, ?, ?, ?, ?
)';
$statement = $connection->prepare($sql);
$statement->bind_param('sssss', $firstName, $lastName, $email, $username, $passwordHash);
$statement->execute();
// Signalize that a new account was successfully created.
$accountCreated = TRUE;
// Reset all values so that they are not shown in the form anymore.
$firstName = $lastName = $email = $username = $password = NULL;
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />
<meta charset="UTF-8" />
<!-- The above 3 meta tags must come first in the head -->
<title>Demo - Sign Up </title>
<!--<link href="assets/images/favicon.ico" rel="icon" type="image/png" />-->
<!-- CSS assets -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,400,700" rel="stylesheet">
<link href="assets/css/app.css" type="text/css" rel="stylesheet">
<link href="assets/css/signup.css" type="text/css" rel="stylesheet">
<!-- JS assets -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
</head>
<body>
<div class="page-container">
<nav class="navbar">
<ul class="navbar-nav">
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">About Us</a>
</li>
<li>
<a href="#">Login</a>
</li>
<li>
<a href="signup.php" class="active">Sign Up</a>
</li>
</ul>
</nav>
<header class="page-header">
<h2 class="page-title">
Sign Up
</h2>
<div class="page-subtitle">
Hello. We are happy to see you here. Please fill in the form to register.
</div>
</header>
<section class="page-content">
<section class="form-container-outer">
<section class="form-container-inner">
<?php
if (isset($errors)) {
?>
<div class="messages danger">
<?php echo implode('<br/>', $errors); ?>
</div>
<?php
} elseif ($accountCreated) {
?>
<div class="messages success">
You have successfully created your account.
<br/>Would you like to <a href="#">login</a> now?
</div>
<?php
}
?>
<form id="signup-form" action="" method="post">
<div class="form-group">
<label for="firstName">First Name <span class="mandatory">*</span></label>
<input type="text" id="firstName" name="firstName" value="<?php echo isset($firstName) ? $firstName : ''; ?>" placeholder="First Name" required>
</div>
<div class="form-group">
<label for="lastName">Last Name <span class="mandatory">*</span></label>
<input type="text" id="lastName" name="lastName" value="<?php echo isset($lastName) ? $lastName : ''; ?>" placeholder="Last Name" required>
</div>
<div class="form-group">
<label for="email">Email <span class="mandatory">*</span></label>
<input type="email" id="email" name="email" value="<?php echo isset($email) ? $email : ''; ?>" placeholder="Email" required>
</div>
<div class="form-group">
<label for="username">Username <span class="mandatory">*</span></label>
<input type="text" id="username" name="username" value="<?php echo isset($username) ? $username : ''; ?>" placeholder="Username" required>
</div>
<div class="form-group">
<label for="password">Password <span class="mandatory">*</span></label>
<input type="password" id="password" name="password" value="<?php echo isset($password) ? $password : ''; ?>" placeholder="Password" required>
</div>
<button type="submit" id="signupButton" name="submit" value="signup">
Create account
</button>
</form>
</section>
</section>
</section>
<footer class="footer">
© <?php echo date('Y'); ?> <a href="#" title="Demo">Demo</a>. All rights reserved.
</footer>
</div>
</body>
</html>
<?php
/*
* This page contains the code for creating a mysqli connection instance.
*/
// Db configs.
define('HOST', 'localhost');
define('PORT', 3306);
define('DATABASE', 'tests');
define('USERNAME', 'root');
define('PASSWORD', 'root');
/*
* Enable internal report functions. This enables the exception handling,
* e.g. mysqli will not throw PHP warnings anymore, but mysqli exceptions
* (mysqli_sql_exception).
*
* MYSQLI_REPORT_ERROR: Report errors from mysqli function calls.
* MYSQLI_REPORT_STRICT: Throw a mysqli_sql_exception for errors instead of warnings.
*
* @link http://php.net/manual/en/class.mysqli-driver.php
* @link http://php.net/manual/en/mysqli-driver.report-mode.php
* @link http://php.net/manual/en/mysqli.constants.php
*/
$mysqliDriver = new mysqli_driver();
$mysqliDriver->report_mode = (MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
/*
* Create a new db connection.
*
* @see http://php.net/manual/en/mysqli.construct.php
*/
$connection = new mysqli(HOST, USERNAME, PASSWORD, DATABASE, PORT);
<?php
/*
* Include this page in all PHP pages of the application.
*
* This page contains:
* - The APP_ENV constant, used to decide in which environment this application runs.
* - The functions for handling all the errors, or exceptions, raised by the application.
* - The code for setting them as error/exception handlers.
* - The code deciding if the errors should be displayed on the screen. The errors
* display MUST be activated ONLY in the development stage of the application. When
* the website goes live, ALL ERRORS must be written in a/the log file and NO ERRORS
* should be displayed on screen, but only a general, user-friendly message, or a
* custom error page.
*/
/*
* Decide in which environment this application runs. Possible values:
* - 'prod' (app in production, e.g. live). The errors are not displayed, but only logged.
* - 'dev' (app in development). The errors are displayed on screen and logged.
* - 'test' (app in tests). Same as 'dev'.
* - etc.
*/
define('APP_ENV', 'dev');
// Activate the errors/exceptions logging.
ini_set('log_errors', 1);
// Set the error reporting level: report all errors.
error_reporting(E_ALL);
// Decide how to handle the errors/exceptions.
if (APP_ENV === 'prod') { // App in production, e.g. live.
// DON'T display the errors/exceptions on the screen.
ini_set('display_errors', 0);
// Set the handler functions.
set_error_handler('errorHandler');
set_exception_handler('exceptionHandler');
} else { // App in development, tests, etc.
// Display the errors/exceptions on the screen.
ini_set('display_errors', 1);
}
/**
* Error handler:
* - Print a user-friendly message, or show a custom error page.
* - Log the error.
*
* @link http://php.net/manual/en/function.set-error-handler.php set_error_handler.
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
*/
function errorHandler($errno, $errstr, $errfile, $errline) {
echo 'An error occurred during your request. Please try again, or contact us.';
error_log('Error ' . $errno . ' - ' . $errstr . ' in file ' . $errfile . ' on line ' . $errline);
exit();
}
/**
* Exception handler:
* - Print a user-friendly message, or show a custom error page.
* - Log the error.
*
* @link http://php.net/manual/en/function.set-exception-handler.php set_exception_handler.
* @param Exception $exception
*/
function exceptionHandler($exception) {
echo 'An error occurred during your request. Please try again, or contact us.';
error_log('Exception ' . $exception->getCode() . ' - ' . $exception->getMessage() . ' in file ' . $exception->getFile() . ' on line ' . $exception->getLine());
exit();
}
/***************************************/
/* Base settings */
/***************************************/
html {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
*, *:before, *:after {
-moz-box-sizing: inherit;
-webkit-box-sizing: inherit;
box-sizing: inherit;
}
/* Font size: 100% = 16px (in almost all web browsers) */
html, body {
width: 100%;
height: 100%;
min-height: 100%;
margin: 0;
padding: 0;
font-size: 100%;
font-weight: 400;
line-height: 1.8;
color: #000;
font-family: "Open Sans", Verdana, Arial, sans-serif !important;
background-color: #fff;
}
/*
A font size of 1rem means 16px. E.g. 100% of the font size of the "html" tag, which is 16px.
A font size of 0.9375rem means: 0.9375 * 16px = 15px.
From this point on, for font sizes, work with "rem", or "em" units, not anymore with px.
The "rem" units are always relative to the font size of the "html" tag (here 16px, because is set as 100%).
The "em" units are always relative to the font size of the parent tag.
*/
body {
font-size: 0.9375rem;
position: relative;
}
a {
text-decoration: none;
outline: none;
color: #DF9237;
}
a:hover {
text-decoration: none;
outline: none;
color: #000;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
line-height: 1;
font-weight: 300;
}
/* A font size of 2.5rem means: 2.5 * 16px = 40px */
h2 {
font-weight: 300;
font-size: 2.5rem;
}
/***************************************/
/* Fonts settings */
/***************************************/
html, body {
font-family: "Open Sans", Verdana, Arial, sans-serif !important;
}
h1, h2, h3, h4, h5, h6,
.navbar-nav li a,
.page-title,
.page-subtitle {
font-family: "Roboto Condensed", Verdana, Arial, sans-serif !important;
}
/***************************************/
/* Layout settings */
/***************************************/
/* Page container */
/*
The top-padding is the navbar's height (70px) + some additional pixels (30px).
The bottom-padding is the footer's height (60px) + some additional pixels (30px).
*/
.page-container {
/* Making relative position so, that we can absolute position the footer on the bottom */
position: relative;
padding: 100px 30px 90px 30px;
width: 100%;
min-height: 100%;
overflow: hidden;
margin: 0;
background-color: #fff;
}
/* Navigation bar */
/*
Navbar must have a fixed height. Example here: 70px (padding is included because of
box-sizing: border-box in html). Then make the top-padding of the .page-container
the same height (70px) + some additional pixels, in order to avoid overlapping!
*/
.navbar {
height: 70px;
padding: 22px 0 0 0;
margin: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
border-bottom: 1px solid #f3f3f3;
background-color: #fff;
}
.navbar-nav {
margin: 0;
padding: 0 60px;
float: right;
list-style: none;
text-transform: uppercase;
}
.navbar-nav li {
display: block;
float: left;
position: relative;
}
.navbar-nav li a {
padding: 7px;
margin-left: 5px;
color: #000;
font-size: 1rem;
font-weight: 300;
border-bottom: 0px solid transparent;
}
.navbar-nav li a:hover {
color: #DF9237;
}
.navbar-nav li a.active {
color: #DF9237;
}
.navbar-nav li a.active:hover {
color: #000;
}
/* Page header */
.page-header {
margin: 0 0 30px 0;
padding: 0;
text-align: center;
}
.page-title {
margin: 0;
padding: 10px;
color: #DF9237;
text-transform: uppercase;
}
.page-subtitle {
/*margin-top: 10px;*/
padding: 0;
text-align: center;
font-weight: 300;
font-size: 1.0625rem;
font-size: 1.1rem;
}
.page-content {
}
/* Messages */
.messages {
padding: 10px;
margin: 0;
border-radius: 4px;
}
.success {
color: #3c763d;
border-color: #d6e9c6;
background-color: #dff0d8;
}
.danger {
color: #a94442;
border-color: #ebccd1;
background-color: #f2dede;
}
.warning {
color: #8a6d3b;
border-color: #faebcc;
background-color: #fcf8e3;
}
/* Mandatory fields in forms */
.mandatory {
font-size: 0.75rem;
color: #DF9237;
}
/* Footer */
/*
Footer must have a fixed height. Example here: 60px (padding is included because of
box-sizing: border-box in html). Then make the bottom-padding of the .page-container
the same height (60px) + some additional pixels, in order to avoid overlapping!
*/
.footer {
height: 60px;
padding-top: 20px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0;
font-weight: 300;
text-align: center;
background-color: #fff;
}
/* Form */
.form-container-outer {
padding: 30px;
position: relative;
text-align: center;
border-radius: 4px;
background-color: #f4f4f4;
}
.form-container-inner {
display: inline-block;
margin: 0 auto;
padding: 0;
}
.messages {
text-align: left;
}
.messages a {
text-transform: uppercase;
font-weight: 600;
}
.messages.success {
text-align: center;
}
#signup-form {
padding: 20px;
display: inline-block;
text-align: left;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: inline-block;
min-width: 100px;
}
input {
padding: 5px;
width: 250px;
font-size: 0.9375rem;
}
button {
padding: 7px 10px;
display: block;
float: right;
color: #fff;
font-size: 0.9375rem;
cursor: pointer;
border: none;
border-radius: 4px;
background-color: #5cb85c;
}
button:hover {
background-color: #449d44;
}
由于您使用的是正确的哈希函数 ( password_hash
),所以 password
列的长度至少为 255 个字符。
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) DEFAULT NULL,
`last_name` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`username` varchar(100) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
关于php - 使用 PHP、mySQL 和 XAMPP 提交表单时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49603108/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!