Php 我的HTML内容在注册后消失
我正在开发我的第一个php网页。我下载了一个模板。我做了一个注册表,并集成到HTML内容中。当我按下register按钮时,我的php类在数据库中注册用户,然后网站加载页眉和页脚,但不加载页面内容Php 我的HTML内容在注册后消失,php,html,mysql,templates,registration,Php,Html,Mysql,Templates,Registration,我正在开发我的第一个php网页。我下载了一个模板。我做了一个注册表,并集成到HTML内容中。当我按下register按钮时,我的php类在数据库中注册用户,然后网站加载页眉和页脚,但不加载页面内容 <?php require_once ('Connection\connection.php'); class TRegistration { public function TRegistration() {
<?php
require_once ('Connection\connection.php');
class TRegistration
{
public function TRegistration()
{
global $g_sContent;
$g_sContent = '';
}
public function ShowRegisterForm()
{
global $g_sContent;
$g_sContent .= '
<p>
<!-- <table width="274" border="0" align="center" cellpadding="20" cellspacing="20"> -->
<form id="register" action="register.php" method="post" accept-charset="UTF-8">
<fieldset >
<td>First Name</td><td> <input type="text" name="firstname"> </td> </tr><br></br>
<td>Last Name</td><td> <input type="text" name="lastname"> </td> </tr><br></br>
<tr> <td>Email</td><td> <input type="text" name="email"></td> </tr> <br></br>
<tr> <td>Password</td><td> <input type="password" name="pass"></td> </tr> <br></br>
<tr> <td>Confirm Password </td><td><input type="password" name="cpass"></td> </tr> <br></br>
<tr> <td><input id="button" type="submit" name="submit" value="Sign-Up"></td> </tr> </p>
</fieldset >
</form>
<!-- </table> -->
';
}
public function IsFormSent()
{
global $g_sContent;
if(isset($_POST["firstname"]) && isset($_POST["lastname"]) && isset($_POST["email"]) && isset($_POST["pass"]) && isset($_POST["cpass"] ))
{
if($_POST["pass"]==$_POST["cpass"])
{
return true;
} else
{
$g_sContent = "<text-red><p>The password doesn't match. Try again<br></br></p></text-red>";
}
}
return false;
}
public function RegisterUser()
{
global $g_sContent;
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['pass'];
$cpassword = $_POST['cpass'];
global $g_conn;
$query = "INSERT INTO `users` (`ID`,`First Name`,`Last Name`,`Nickname`,`Password`,`Email Address`) VALUES (0,'$firstname','$lastname','','$password','$email')";
$data = $g_conn->query($query);
if($data)
{
$g_sContent .= "<p>Your registration to the HUB it's complete...</p>";
} else
{
$g_sContent .= "<p>Error registering to the HUB... </p>";
}
}
}
$g_sTitle = "Register";
require_once ('Template\header.php');
$g_sContentTitle = '<b>Register</b> to the HUB</b>';
global $g_sContent;
$Register = new TRegistration();
if ($Register->IsFormSent() == false)
$Register->ShowRegisterForm();
else
{
$Register->RegisterUser();
$g_sContent .= "<p>Error registering to the HUB... </p>";
}
require_once ('Template\content.php');
//include 'Template\footer.php';
?>
Template\content.php中的内容是什么?尝试回显“内容页”content.php
文件中的code>应该可以正常响应。content.php本身就是模板。我尝试了很多次,但是内容是使用动画动态加载的。考虑到您有以下内容,您可以从这里访问content.php:require_once('Template\content.php');包括“Template\footer.php”
一个接一个地,在任何条件语句之外,没有理由不显示它们,除非它没有找到content.php
。如果将这两行更改为require_once('Template\footer.php');包括“Template\footer.php”
是否看到页脚两次?您的php代码很好,要么您的样式使内容页从您看到的内容中“消失”,要么content.php
无法访问