PHP文档中未加载HTML
我正在编写一个基本的PHP登录/注册脚本,由于某种原因,只要添加一个PHP命令,HTML就不会加载。我查看了源代码,但根本没有加载任何内容。我希望我错过了一些非常基本的东西,但是我在web服务器上安装的PHP版本也有一些初期问题PHP文档中未加载HTML,php,html,Php,Html,我正在编写一个基本的PHP登录/注册脚本,由于某种原因,只要添加一个PHP命令,HTML就不会加载。我查看了源代码,但根本没有加载任何内容。我希望我错过了一些非常基本的东西,但是我在web服务器上安装的PHP版本也有一些初期问题 <?php require_once('connect.php'); if(isset($_POST) & !empty($_POST)){ $username = mysql_real_escape_string($_POST['userna
<?php
require_once('connect.php');
if(isset($_POST) & !empty($_POST)){
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$password =md5($_POST['password']);
$sql = "INSERT INTO 'login' (username, email, password) VALUES ('$username, $email, $password)";
$result = mysql_query($connection, $sql);
if($result){
echo "User Rego Secusseflllgk";
}else{
echo "User rego faile";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>USer Reg in PHP & MySQL</title>
</head>
<center>
<body>
<div class="container">
<form class="form-signin" method="POST">
<h2 class="form-sigin-heading">Please register</h2>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">@</span>
<input type="test" name="username" class="form-control" placeholder="Username" required>
</div>
<label for="inputEmail" class="sr-only">Password</label>
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
<a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
</form>
</div>
</body>
</html>
用这个
if(isset($_POST['email']) && !empty($_POST['email'])){
您正在使用不推荐使用的函数,并且您的if语句不正确 使用
if(isset($\u POST)和&!empty($\u POST)){
mysql\u查询
应该是mysqli\u查询
,您使用的函数:
混合mysql\u查询(字符串$query[,资源$link\u identifier=NULL])
与新版本相比:
混合mysqli\u查询(mysqli$link,string$query[,int$resultmode=mysqli\u STORE\u RESULT])
您首先放置的是连接,然后是查询,这对mysql\u查询不起作用。在mysqli\u查询中,标记确实起作用。检查并查看下面的代码
<?php
require_once('connect.php');
if(isset($_POST) & !empty($_POST)){
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$password =md5($_POST['password']);
$sql = "INSERT INTO login (username, email, password) VALUES ('".$username."', '".$email."', '".$password."')";
$result = mysql_query($sql);
if($result){
echo "User Rego Secusseflllgk";
}else{
echo "User rego faile";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>USer Reg in PHP & MySQL</title>
</head>
<center>
<body>
<div class="container">
<form class="form-signin" method="POST">
<h2 class="form-sigin-heading">Please register</h2>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">@</span>
<input type="test" name="username" class="form-control" placeholder="Username" required>
</div>
<label for="inputEmail" class="sr-only">Email</label>
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
<a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
</form>
</div>
</body>
</html>
您是否使用Apache2这样的web服务?目前它托管在运行PHP7.0的net registry服务器上。我在这里测试了5.3和5.6。错误日志中没有错误,并且我测试了$connection实际上建立了与mysql的连接。感谢Hespen,我还在康涅狄格州交换mysql和msqli在scriptYou上,您说您使用的是PHP 7.00,而mysql函数当时都被mysqli替换了!如果您运行的是旧版本,您可能会侥幸逃脱。请记住:当使用PHP编写代码时,您的页面是空白的。您在某个地方遇到了PHP错误。
<?php
require_once('connect.php');
if(isset($_POST) & !empty($_POST)){
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$password =md5($_POST['password']);
$sql = "INSERT INTO login (username, email, password) VALUES ('".$username."', '".$email."', '".$password."')";
$result = mysql_query($sql);
if($result){
echo "User Rego Secusseflllgk";
}else{
echo "User rego faile";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>USer Reg in PHP & MySQL</title>
</head>
<center>
<body>
<div class="container">
<form class="form-signin" method="POST">
<h2 class="form-sigin-heading">Please register</h2>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">@</span>
<input type="test" name="username" class="form-control" placeholder="Username" required>
</div>
<label for="inputEmail" class="sr-only">Email</label>
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
<a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
</form>
</div>
</body>
</html>