错误:
不推荐使用:mysql_connect():不推荐使用mysql扩展,将来会删除它:在第6行的/home/u251789135/public_html/omg/admin/Connection/config.php中使用mysqli或PDO
警告:mysql_connect():用户'U251789135_user'@'10.2.1.35'(使用密码:是)拒绝访问/home/u251789135/public_html/omg/admin/Connection/config.php 6 无法连接到服务器:用户'U251789135_user'@'10.2.1.35'拒绝访问(使用密码:是)
内部管理员/连接目录,他们是两个配置文件。代码如下:
Config.php:http://pastebin.com/fJiGGCdK
conn.php:
我无法将其粘贴到此处。编辑说它包含的代码格式不正确。所以我会使用粘贴框:http://pastebin.com/en2WWquW
我在发生错误时尝试打开管理页面。特别是:admin / login-exec.php和admin / tracking-exec.php。
admin / login-exec.php代码:
<?php
//Start session
session_start();
//Include database connection details
require_once('Connection/config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$login = clean($_POST['username']);
$password = clean($_POST['pass']);
//Input Validations
if($login == '') {
$errmsg_arr[] = 'Empty username not allowed';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Empty password not allowed';
$errflag = true;
}
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
//Create query
$qry="SELECT * FROM admin WHERE username='$login' AND password='$password'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$user = mysql_fetch_assoc($result);
$_SESSION['USER_ADMIN_ID'] = $user['username'];
session_write_close();
header("location: view.php");
exit();
}else {
//Login failed
$errmsg_arr[] = 'Provide a valid user name and password';
$errflag = true;
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
}
}else {
die("Query failed");
}
&GT;
我需要帮助修复错误。我不知道php。我希望我提供了所有必要的信息。