when i run the register.php page form doen not show in browser
this is my whole code....
register.php
Registration Here
class.php
include ("config.php");
class User{
public $db;
public function __construct(){
$this->db = new mysqli('localhost', 'root', 'iws123#', 'register');
if(mysqli_connect_errno()) {
echo "Error: Could not connect to database.";
exit;
}
}
/*** for registration process ***/
public function reg_user($first_name,$last_name,$username,$email,$password,$type)
{
$sql="SELECT * FROM user_table2 WHERE username='$username'";
//checking if the username or email is available in db
$check = $this->db->query($sql) ;
$count_row = $check->num_rows;
//if the username is not in db then insert to the table
if ($count_row == 0){
$sql1="INSERT INTO user_table2 SET first_name='".$first_name."',last_name ='".$last_name."', username='".$username."',email='".$email."',password='".$password."',type='".$type."'";
$result = mysqli_query($this->db,$sql1) or die(mysqli_connect_errno()."Data cannot inserted");
return $result;
}
else { return false;}
}
/*** for login process ***/
public function check_login($emailusername, $password){
$sql2="SELECT id from user_table2 WHERE username='$username' and password='$password'";
//checking if the username is available in the table
$result = mysqli_query($this->db,$sql2);
$user_data = mysqli_fetch_array($result);
$count_row = $result->num_rows;
if ($count_row == 1) {
// this login var will use for the session thing
$_SESSION['login'] = true;
$_SESSION['id'] = $user_data['id'];
return true;
}
else{
return false;
}
}
/*** starting the session ***/
public function get_session(){
return $_SESSION['login'];
}
public function user_logout() {
$_SESSION['login'] = FALSE;
session_destroy();
}
}
?>
class User{
public $db;
public function __construct(){
$this->db = new mysqli('localhost', 'root', 'iws123#', 'register');
if(mysqli_connect_errno()) {
echo "Error: Could not connect to database.";
exit;
}
}
/*** for registration process ***/
public function reg_user($first_name,$last_name,$username,$email,$password,$type)
{
$sql="SELECT * FROM user_table2 WHERE username='$username'";
//checking if the username or email is available in db
$check = $this->db->query($sql) ;
$count_row = $check->num_rows;
//if the username is not in db then insert to the table
if ($count_row == 0){
$sql1="INSERT INTO user_table2 SET first_name='".$first_name."',last_name ='".$last_name."', username='".$username."',email='".$email."',password='".$password."',type='".$type."'";
$result = mysqli_query($this->db,$sql1) or die(mysqli_connect_errno()."Data cannot inserted");
return $result;
}
else { return false;}
}
/*** for login process ***/
public function check_login($emailusername, $password){
$sql2="SELECT id from user_table2 WHERE username='$username' and password='$password'";
//checking if the username is available in the table
$result = mysqli_query($this->db,$sql2);
$user_data = mysqli_fetch_array($result);
$count_row = $result->num_rows;
if ($count_row == 1) {
// this login var will use for the session thing
$_SESSION['login'] = true;
$_SESSION['id'] = $user_data['id'];
return true;
}
else{
return false;
}
}
/*** starting the session ***/
public function get_session(){
return $_SESSION['login'];
}
public function user_logout() {
$_SESSION['login'] = FALSE;
session_destroy();
}
}
?>
login.php
Login Here
home.php
LOGOUT
Hello get_username($id); ?>
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Thiruppathi RPosted Jun 7, 2017, 8:10 AM