created new dbname and login for upcoming tasks of casestudy

This commit is contained in:
Ivan Hörler 2017-02-16 12:16:41 +01:00
parent 678f54672e
commit 562ad9fd8e
4 changed files with 54 additions and 42 deletions

View File

@ -2,9 +2,9 @@
class Database
{
private $host = "localhost";
private $db_name = "dblogin";
private $username = "root";
private $password = "";
private $db_name = "bsldb";
private $username = "WT1CS1usr";
private $password = "ibz4life-WT1CS1";
public $conn;
public function dbConnection()

View File

@ -1,39 +1,52 @@
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 07, 2016 at 03:05 AM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `dblogin`
--
CREATE DATABASE IF NOT EXISTS bsldb
CHARACTER SET `utf8`
COLLATE utf8_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `users`
-- use database and create user
--
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(15) NOT NULL,
`user_pass` varchar(255) NOT NULL,
`joining_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
use bsldb;
grant all on bsldb.* to
'WT1CS1usr'@'%'
identified by 'ibz4life-WT1CS1';
flush privileges;
SHOW GRANTS FOR 'WT1CS1usr';
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
--
-- Table structure
--
CREATE TABLE IF NOT EXISTS `bsldb`.`benutzer` (
`benutzer_id` int(11) NOT NULL AUTO_INCREMENT,
`benutzer_name` varchar(15) NOT NULL,
`benutzer_pass` varchar(255) NOT NULL,
`anmelde_datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE (`benutzer_name`),
PRIMARY KEY (`benutzer_id`)
) ;
CREATE TABLE IF NOT EXISTS `bsldb`.`nachfrager` (
`erfassungs_id` int(11) NOT NULL AUTO_INCREMENT,
`benutzer_id` int(11) NOT NULL,
`nachfr_typ` varchar(15) NOT NULL,
`nachfr_quali` varchar(15) NOT NULL,
`nachfr_menge` int(11) NOT NULL,
`nachfr_lieferdatum` date,
`nachfr_datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `pk_nachfrager_erfassungs_id`
PRIMARY KEY (erfassungs_id),
CONSTRAINT `fk_nachfrager_benutzer_id`
FOREIGN KEY (benutzer_id) REFERENCES `benutzer` (benutzer_id)
) ;
CREATE TABLE IF NOT EXISTS `bsldb`.`anbieter` (
`angebot_id` int(11) NOT NULL AUTO_INCREMENT,
`benutzer_id` int(11) NOT NULL,
`erfassungs_id` varchar(15) NOT NULL,
`angebot_preis` varchar(255) NOT NULL,
`angebot_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`angebot_id`),
FOREIGN KEY (`benutzer_id`) REFERENCES benutzer(`benutzer_id`)
) ;

View File

@ -5,7 +5,6 @@
require_once("class.user.php");
$auth_user = new USER();
$user_id = $_SESSION['user_session'];
$stmt = $auth_user->runQuery("SELECT * FROM users WHERE user_id=:user_id");

View File

@ -1,15 +1,15 @@
<?php
session_start();
require_once 'class.user.php';
$session = new USER();
// if user session is not active(not loggedin) this page will help 'home.php and profile.php' to redirect to login page
// put this file within secured pages that users (users can't access without login)
// put this file within secured pages that users can't access without login!
if(!$session->is_loggedin())
{
// session no set redirects to login page
$session->redirect('index.php');
}
}