我正在为我的第一个php网页工作。我下载了一个模板。我做了一个注册表并集成在HTML内容中。当我按下注册按钮时,我的php类在数据库中注册用户,然后网站加载页眉和页脚,但不加载页面的内容。
<?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';
?>
模板正在使用js/waypoints.min.js
为内容制作动画。
Content.php
可在此处访问:http://pastebin.com/2yqu3eVL