I currently use PHP for all my server side processing and database interaction with my b4x apps. It would be nice to use JRDC2, but I'm not certain if it will do what I need. Can you do processing on the server side before sending results?
Example:
1). Client sends email address and password to the server.
2). Server checks to see if the password is valid.
3). Server response includes the full user record (without the password) or a response indicating that the login was unsuccessful.
Or, something like code below that resets a password. PHP works fine for me, but I like the idea of the added security of JRDC2.
Example:
1). Client sends email address and password to the server.
2). Server checks to see if the password is valid.
3). Server response includes the full user record (without the password) or a response indicating that the login was unsuccessful.
Or, something like code below that resets a password. PHP works fine for me, but I like the idea of the added security of JRDC2.
B4X:
<?php
$serverName = "";
$connectionOptions = array("Database" => "",
"UID" => "",
"PWD" => "");
$con = sqlsrv_connect($serverName, $connectionOptions);
// Was the form submitted?
if (isset($_POST["ResetPasswordForm"]))
{
// Gather the post data
$email = $_POST["email"];
$password = $_POST["password"];
$confirmpassword = $_POST["confirmpassword"];
$hash = $_POST["q"];
if (strlen($password)<6) {
die("<h1>Password must be at least 6 characters long</h1>");
}
// Use the same salt from the forgot_password.php file
$salt = "498#2DDDB631%38EBD!801600D*7E34444";
// Generate the reset key
$resetkey = hash('sha512', $salt.$email);
// Does the new reset key match the old one?
if ($resetkey == $hash)
{
if ($password == $confirmpassword)
{
// Update the user's password
$tsql=" update usertable set passwordhash=HASHBYTES('SHA2_512', ?+CAST(salt AS NVARCHAR(36))) where email=?";
$params = array(&$password ,&$email );
/* Prepare and execute the statement. */
$insertReview = sqlsrv_prepare($con, $tsql, $params);
if( $insertReview === false )
{
echo "<h1>Sorry. We were unable to reset your password. Please contact support@mindware.mobi for help.</h1>";
} else {
$sth=sqlsrv_execute($insertReview);
if ($sth == FALSE)
{
echo "<h1>Sorry. We were unable to reset your password. Please contact support@mindware.mobi for help.</h1>";
}
echo "<h1>Your password has been successfully reset.</h1>";
}
}
else
echo "<h1>Your password's do not match.</h1>";
}
else
echo "<h1>Your password reset key is invalid.</h1>";
}
?>