Hi- I've got some code calling a stored procedure from php and it isn't giving me any errors, but it isn't giving me the results I expect either. I think maybe I am not feeding the variable to SQL as needed.
when I run the command: sp_encrypt_text 'password', '@returnencrypted'
in SQL 2005 I get "Command completed successfully, but I don't get the encrypted password returned.
when I use SQL execute commands, I get the following script to get the encrypted password:
DECLARE @return_value int,
@return_encrypted varchar(255)
EXEC @return_value = [dbo].[sp_encrypt_text]
@unencrypted = N'$password',
@return_encrypted = @return_encrypted OUTPUT
SELECT @return_encrypted as N'@return_encrypted'
SELECT 'Return Value' = @return_value
GO
In PHP right now I have the following:
if ($this->config->passtype === 'md5') { // Re-format password accordingly
$extpassword = md5($extpassword);
} else if ($this->config->passtype === 'sha1') {
$extpassword = sha1($extpassword);
}
elseif($this->config->passtype === 'pc')
{
$extpassword = $authdb->query("call sp_encrypt_text($extpassword, $extpassword)");
}
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'
AND {$this->config->fieldpass} = '".$this->ext_addslashes($extpassword)."' ");
if (!$rs) {
$authdb->Close();
print_error('auth_dbcantconnect','auth');
return false;
}
if (!$rs->EOF) {
$rs->Close();
$authdb->Close();
return true;
} else {
$rs->Close();
$authdb->Close();
return false;
}
It doesn't give me any errors but when I enter a password, it doesn't allow me to login, which means it isn't successfully authenticating against that stored procedure. Can anyone help me?
Thanks!