Click here to Skip to main content
15,032,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
config.php file

PHP
<?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 file

PHP
<?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 file

C#
<?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 file

XML
<?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>




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
Posted
Comments
Rakesh 00 2-Feb-15 14:20pm
   
Is anyone there to help?????????????????????????
ZurdoDev 2-Feb-15 15:08pm
   
1. Please be patient. This is a volunteer site.
2. I don't do PHP but if it works by removing that then why do you need it and if you do need it then there is likely an error in it since it won't work when you do include it.
ZurdoDev 2-Feb-15 15:08pm
   
And do not repost.
Mohibur Rashid 3-Feb-15 1:44am
   
You did not include message.php anywhere. But you are trying to use the defined macros.
Your error_reporting is turned off. That is why, when there is a error your page will turn blank.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900