forked from jayesh15111988/JKPatternLock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorePasswordInDatabase.php
More file actions
58 lines (36 loc) · 2.38 KB
/
StorePasswordInDatabase.php
File metadata and controls
58 lines (36 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once( "db_info.php" );
//echo $_GET['username']." ".$_GET['password'];
$userNameProvider = $mysqli->real_escape_string($_GET['username']);
$passwordProvider = $mysqli->real_escape_string($_GET['password']);
$query = "select password from gesturepassword where username= '" . $userNameProvider . "'";
$queryrun = $mysqli->query( $query ) or die( $mysqli->error . __LINE__ );
if ( $queryrun->num_rows > 0 ) {
//$row = mysql_fetch_array($queryrun);
while ( $row = $queryrun->fetch_assoc() ) {
if ( !strcmp( $row['password'], $passwordProvider ) ) {
//Successful and unlock doors
echo "Welcome " . $_GET['username'];
//$row->close();
}
else {
//failed authentication
echo "Username " . $_GET['username'] . " already exists. <br/> We checked it against existing Password and we got an authentication Failure";
}
}
}
else {
$result = $mysqli->query( "insert into gesturepassword(password,username) values (
'" . $passwordProvider . "' ,'" . $userNameProvider . "')" ) or die( $mysqli->error . __LINE__ );
if ( $result ) {
//insert successful
echo "Success!<br/> Your username " . $_GET['username'] . " successfully stored along with<br/> password pin: " . $_GET['password'] . "<br/> Please remember it for the next login";
} //$result
else {
//insert failure
echo "Failure in insertion";
die( 'Invalid query: ' . mysql_error() );
}
}
$mysqli->close();
?>