body {font-weight: bold}
p {font-weight: normal}
public static function getNewsList()
{
// Запрос к БД
$host = 'xxxxxx';
$dbname = 'xxxxxx';
$user = 'xxxxx';
$password = 'xxxxxx';
$db = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
$newsList = array();
$result = $db->query('SELECT id, title, date, short_content '
. 'FROM news'
. 'ORDER BY date DESC '
. 'LIMIT 10');
$i = 0;
while($row = $result->fetch()){
$newsList[$i]['id'] = $row['id'];
$newsList[$i]['title'] = $row['title'];
$newsList[$i]['date'] = $row['date'];
$newsList[$i]['short_content'] = $row['short_content'];
$i++;
}
return $newsList;
}
}
<?php
include_once '../admin/include/connect.php';
//============================================================================//
// FUNCTION FOR LOGIN //
//============================================================================//
function login($username, $password){
global $objCon;
if($username != '' && $password != ''){
$checkUser = $objCon->query("SELECT username FROM mettes_user WHERE username = '$username' LIMIT 1");
$checkAdmin = $objCon->query("SELECT username, password, admin FROM rest_user WHERE username = '$username' AND password = '$password' AND admin = 1");
$checkPass = $objCon->query("SELECT username, password FROM mettes_user WHERE username = '$username' AND password = '$password' LIMIT 1");
if(mysqli_num_rows($checkUser) != 1){
header('Location: /Planteskole/index.php?page=home&error=2');
}elseif(mysqli_num_rows($checkPass) != 1){
header('Location: /Planteskole/index.php?page=home&error=3');
}elseif(mysqli_num_rows($checkAdmin) >= 1){
session_start();
$_SESSION['username'] = $username; // for Admin
header('Location: /Planteskole/admin/index.php');
}else{
session_start();
$_SESSION['username'] = $username; // For user
header('Location: /Planteskole/index.php');
}
}else{
header('Location: /Planteskole/index.php?page=home&error=1');
}
}
?>