require_once显示空白页面 [英] require_once showing blank page
本文介绍了require_once显示空白页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
config.php文件
config.php file
<?php
require_once 'messages.php';
//site specific configuration declartion
define( 'BASE_PATH', 'http://localhost/user_login/');
define( 'DB_HOST', 'localhost' );
define( 'DB_USERNAME', 'root');
define( 'DB_PASSWORD', 'ricky');
define( 'DB_NAME', 'user_login');
function __autoload($class)
{
$parts = explode('_', $class);
$path = implode(DIRECTORY_SEPARATOR,$parts);
require_once $path . '.php';
}
function.php文件
function.php file
<?php
class users
{
protected $_con;
public function __construct()
{
$db=new DataBase();
$this->_con=$db->con;
}
public function insert(array $data)
{
if(!empty($data)){
$trimmed_data=array_map('trim',$data);
$username=mysqli_real_escape_string($this->_con,$trimmed_data['username']);
$password=mysqli_real_escape_string($this->_con,$trimmed_data['password']);
$email=mysqli_real_escape_string($this->_con,$trimmed_data['email']);
$name=mysqli_real_escape_string($this->_con,$trimmed_data['name']);
$sql="insert into users(username,password,email,name) values(NULL,'$username','$password','$email','$name')";
if(mysqli_query($this->_con,$sql)) return TRUE;
}else{
throw new Exception(USER_REGISTRATION_FAIL);
}
}
}
?>
message.php文件
message.php file
<?php
define('FIELDS_MISSING', 'Some Fields Are Missing');
define('PASSWORD_NOT_MATCH', 'Passwords do not match');
define('USER_REGISTRATION_FAIL', 'User registration failed');
define('USER_REGISTRATION_SUCCESS', 'User registration was successful, You may login now');
define('LOGIN_FIELDS_MISSING', 'Email and Password are missing');
define('LOGIN_FAIL', 'Email and Password are mismatch');
define('PASSOWRD_CHANAGE_SUCCESS', 'Password changed successfully.');
?>
registration.php文件
registration.php file
<?php
require_once 'config.php';
?>
<?php
if(!empty($_POST)){
try {
$user_obj = new users();
$data = $user_obj->insert( $_POST );
if($data)$success = USER_REGISTRATION_SUCCESS;
} catch (Exception $e) {
$error = $e->getMessage();
}
}
?>
<!doctype html>
<html>
<body>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" name='reg' >
Full Name
<input type="text" name="username"/>
Password
<input type="password" name="password"/>
Name
<input type="text" name="name"/>
Email
<input type="text" name="email"/>
<input type="submit" name="submit" value="Register"/>
</form>
</body></html>
当我运行我的注册页面时,它显示空白,带有require_once.But当我移动require一次然后它显示我的表格。请建议
when I run my registration page it show blank with require_once.But when I move the require once then it show me the form.Please suggest
推荐答案
class)
{
class) {
parts = explode(' _',
class);
class);
这篇关于require_once显示空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文