我正在编写一个代码来验证我的mysql数据库中的数据。
我的剧本几乎是"准备好,但我不知道如何成功使用密码。
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$shapass=sha1($password);
$query = mysql_query("select * from alw73_users where password='$shapass' AND username='$username'", $connection);
但不行。未成功验证。我认为Joomla不使用sha1进行密码编码,也许我完全做错了。但是我应该使用什么?
脚本结束:
$rows = mysql_num_rows($query);
if ($rows == 1) {
$error = "OK";
echo "OK";
} else {
$error = "NOT OK";
echo "BAD!";
}
答案 0 :(得分:0)
以下是我在外部脚本中初始化Joomla Framework变量的方法,这可能会对您有所帮助。
if ($JEXEC_defined==TRUE) {
defined('_JEXEC') OR defined('_VALID_MOS') OR die( 'Restricted access' ); //security reason
$direct_script_access=FALSE;
}
if ($JEXEC_defined==FALSE) {
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', dirname(__FILE__) );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$direct_script_access=TRUE;
// initialize the application
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
}
if ($user->username!="") if ($direct_script_access==TRUE) {
//PHP code when script is accessed directly
}