Skip to content
Snippets Groups Projects
Commit 9ca2d44a authored by Raghav's avatar Raghav
Browse files

Verified User password with simple way: Success

parent 1cab2e0d
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ class User ...@@ -9,7 +9,7 @@ class User
$conn = Database::getConnection(); $conn = Database::getConnection();
// To save password as md5 hash format // To save password as md5 hash format
$pass = md5($pass); $pass = md5(strrev(md5($pass))); //Security through obscurity
$sql = "INSERT INTO `auth` (`username`, `password`, `email`, `phone`, `block`, `active`) $sql = "INSERT INTO `auth` (`username`, `password`, `email`, `phone`, `block`, `active`)
VALUES ('$user', '$pass', '$email', '$phone', '0', '1');"; VALUES ('$user', '$pass', '$email', '$phone', '0', '1');";
...@@ -27,20 +27,38 @@ class User ...@@ -27,20 +27,38 @@ class User
return $error; return $error;
} }
public static function getCredential($email, $pass) // Check whether the user credential is exists in database
{ public static function login($user, $pass){
// Since it is in static function we need to declare again in this function.
$password = $pass;
// Connect to Database // store query in a variable
$query = "SELECT * FROM `auth` WHERE `username` = '$user'";
// To get database connection
$conn = Database::getConnection(); $conn = Database::getConnection();
Database::getUserData($email, $pass); // sends the query with query() to get the data from database
$result = $conn -> query($query);
} /*
[*] Accessing (num_rows) is the variable present inside the class eg: $object->variable_name;
*/
if($result -> num_rows == 1){
// fetch data as array from database and store in $row
$row = $result->fetch_assoc();
// validate password from database
if($row['password'] == $password){
return $row;
}else{
return false;
}
}else{
return false;
}
public static function setCredential()
{
Database::setUserData();
} }
} }
<?php
include 'libs/load.php';
$user = "devyani ";
$pass = "devyani";
$result = User::login($user, $pass);
if ($result) {
echo "Login success";
} else {
echo "Login failed";
}
<?php
$str = <<<"raghav"
[*] Hello I am raghav fro selfmade ninja
[*] here we are going to see about hashing [md5] how md5() works
[*] Is it stores the whole data into 32bit data?
[*} Hey buddy what's up????
raghav;
echo "string length: " . strlen($str) . "\n";
echo "md5: ". md5($str) . "(length: ". strlen(md5($str)) . ")\n";
echo "base64: ". base64_encode($str) . "\n(Length: ". strlen(base64_encode($str)) . ")";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment