diff --git a/README.md b/README.md
index ac94635..fea22b4 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,50 @@
# Simple_PHP_Auth
A Personal PHP Auth which you might find useful. Created for a Faster deployment of your Authentication Web App.
+I Basically use it for simple login/Register and stuffs like that.
+
+# How to Use
+
+You can take hold of this lib by.
+
+1. Starting up your terminal and punching
+
+$ git clone https://github.com/Kofacts/Simple_PHP_Auth.git
+
+
+2. Having done that, the package would be installed in a folder named "Simple_PHP_Auth"
+
+
+3. Create a New instance of the login class which takes two params. Connection name and DB Name with table users_details.
+
+ $login = new login($connect,"user_details");
+
+4. Having done that, You can verify a user by calling.
+
+$login->verifyLogin($_POST['username'],$_POST['password'],$callback_url,$error_message);
+
+5. You can also Check if the user is loggedin via:
+
+$login->isLoggedin();
+
+
+6. To register, you can use
+
+$login->register($username,$password,$email,$telephone,$address); in this order
+
+7. Once the user is loggedin, you can redirect the user using the "redirect($url) method";
+
+$login->redirect($url);
+
+Actually more features are still been added.
+
+# I Saw a Bug..
+Wheew. That's Awesome, Do send me a mail obodugorapheal[at]gmail.com
+
+# Contribute?
+DO Send me a pull request.
+
+# How to Thank Me?
+Just Star. Actually... Em, that's just it.
+
+
+
diff --git a/src/Auth.php b/src/Auth.php
index aa8639d..94dc49e 100644
--- a/src/Auth.php
+++ b/src/Auth.php
@@ -1,17 +1,51 @@
isAlwaysLoggedin();
+
+
}
- public static void user()
+ static function username()
{
-
+ //Use this method to echo the name of the guest.
+ echo $username;
+
+ }
+
+ static function email()
+ {
+ echo $email;
+ }
+
+ static function addr()
+ {
+ echo $address;
+ }
+
+ public function isAlwaysLoggedin()
+ {
+ //Check if the user is logged in else redirect.
+ if($this->isLoggedin()==TRUE)
+ {
+ return true;
+ }
+ else{
+ die("You Need to log in");
+ }
}
}
\ No newline at end of file
diff --git a/src/login.php b/src/login.php
index e291e40..c27b0aa 100644
--- a/src/login.php
+++ b/src/login.php
@@ -1,4 +1,6 @@
tablename=$tablename;
}
- public function verifyLogin($username,$password,$callback,$errormessage1,$errormessage2)
+ /**
+ * @param needs the username, password, error message to display
+ * Error message can be encapsulated into HTML codes.
+ **/
+
+ public function verifyLogin($username,$password,$errormessage1,$errormessage2)
{
//Verify the user.
//Check the db first.
$this->username=$username;
$this->password=$password;
- $this->callback-$callback;
+ //$this->callback=$callback;
$username1=$this->username;
$password1=$this->password;
$search1="SELECT * FROM $this->tablename WHERE username='$username1' AND password='$password1'";
@@ -50,7 +61,7 @@ public function verifyLogin($username,$password,$callback,$errormessage1,$errorm
session_start();
$_SESSION['username']=$this->username;
$_SESSION['password']=$this->password;
- header("Location: $callback");
+ //Stores just the session.
ob_flush();
}
elseif(!$search11->num_rows>0)
@@ -73,6 +84,25 @@ public function verifyLogin($username,$password,$callback,$errormessage1,$errorm
}
}
+ public function redirect($url)
+ {
+ header("Location: $url");
+ }
+
+ public function isLoggedin()
+ {
+ //Once the user is logged in.
+
+ if($_SESSION['username']==$this->username && $_SESSION['password']==$this->password)
+ {
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+
public function logout()
{
diff --git a/test/index.php b/test/index.php
index d032e1d..029981c 100644
--- a/test/index.php
+++ b/test/index.php
@@ -1,5 +1,8 @@
verifyLogin($_POST['username'],$_POST['password'],"http://facebook.com","Failed Login","Error");
+ $login= new l\login($connect,"user_details");
+ //Logs the user in first.
+ $login->verifyLogin($_POST['username'],$_POST['password'],"Failed Login","Error");
+
+ if($login->isLoggedin()==TRUE)
+ {
+ //Checks when the user is loggedin in..
+ $auth= new details\Auth();
+ $auth::guest();
+ }
+ else{
+ $login->redirect("http://scholarsjoint.com");
+ }
//$login::guest();
}
}