Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingo Mägi Lõputöö #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Class/Helper.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
class Helper {

function cleanInput($input){

$input = trim($input);
$input = stripslashes($input);
$input = htmlspecialchars($input);

return $input;

}




}?>
86 changes: 86 additions & 0 deletions Class/user.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
class User {
private $connection;
public $name;
function __construct($mysqli){

$this->connection=$mysqli; //this on user

}

function signUp ($email, $password, $name, $roll, $age, $county) {
$this->connection->set_charset("utf8");
$stmt = $this->connection->prepare("INSERT INTO user_sample (email, password, name, roll, vanus, elukoht) VALUES (?, ?, ?, ?, ?, ?)");

echo $this->connection->error;

$stmt->bind_param("ssssss", $email, $password, $name, $roll, $age, $county);

if($stmt->execute()) {
echo "salvestamine õnnestus";
} else {
echo "ERROR ".$stmt->error;
}

$stmt->close();
//$this->connection->close();

}
function login ($email, $password) {

$error = "";

$stmt = $this->connection->prepare("
SELECT id, email, password, created
FROM user_sample
WHERE email = ?");

echo $this->connection->error;

//asendan küsimärgi
$stmt->bind_param("s", $email);

//määran väärtused muutujatesse
$stmt->bind_result($id, $emailFromDb, $passwordFromDb, $created);
$stmt->execute();

//andmed tulid andmebaasist või mitte
// on tõene kui on vähemalt üks vaste
if($stmt->fetch()){

//oli sellise meiliga kasutaja
//password millega kasutaja tahab sisse logida
$hash = hash("sha512", $password);
if ($hash == $passwordFromDb) {

echo "Kasutaja logis sisse ".$id;

//määran sessiooni muutujad, millele saan ligi
// teistelt lehtedelt
$_SESSION["userId"] = $id;
$_SESSION["userEmail"] = $emailFromDb;

$_SESSION["message"] = "<h1>Tere tulemast!</h1>";

header("Location: frontpage.php");
exit();

}else {
$error = "vale parool";
}


} else {

// ei leidnud kasutajat selle meiliga
$error = "ei ole sellist emaili";
}

return $error;

}



}
?>
61 changes: 61 additions & 0 deletions Page/cart_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
require("../functions.php");
include_once("config.php");

//add product to session or create new one
if(isset($_POST["type"]) && $_POST["type"]=='add' && $_POST["product_qty"]>0)
{
foreach($_POST as $key => $value){ //add all post vars to new_product array
$new_product[$key] = filter_var($value, FILTER_SANITIZE_STRING);
}
//remove unecessary vars
unset($new_product['type']);
unset($new_product['return_url']);

//we need to get product name and price from database.
$statement = $mysqli->prepare("SELECT product_name, price FROM products WHERE product_code=? LIMIT 1");
$statement->bind_param('s', $new_product['product_code']);
$statement->execute();
$statement->bind_result($product_name, $price);

while($statement->fetch()){

//fetch product name, price from db and add to new_product array
$new_product["product_name"] = $product_name;
$new_product["product_price"] = $price;

if(isset($_SESSION["cart_products"])){ //if session var already exist
if(isset($_SESSION["cart_products"][$new_product['product_code']])) //check item exist in products array
{
unset($_SESSION["cart_products"][$new_product['product_code']]); //unset old array item
}
}
$_SESSION["cart_products"][$new_product['product_code']] = $new_product; //update or create product session with new item
}
}


//update or remove items
if(isset($_POST["product_qty"]) || isset($_POST["remove_code"]))
{
//update item quantity in product session
if(isset($_POST["product_qty"]) && is_array($_POST["product_qty"])){
foreach($_POST["product_qty"] as $key => $value){
if(is_numeric($value)){
$_SESSION["cart_products"][$key]["product_qty"] = $value;
}
}
}
//remove an item from product session
if(isset($_POST["remove_code"]) && is_array($_POST["remove_code"])){
foreach($_POST["remove_code"] as $key){
unset($_SESSION["cart_products"][$key]);
}
}
}

//back to return url
$return_url = (isset($_POST["return_url"]))?urldecode($_POST["return_url"]):''; //return url
header('Location:'.$return_url);

?>
19 changes: 19 additions & 0 deletions Page/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
$currency = '&#8364; '; //Currency Character or code

$db_username = 'if16';
$db_password = 'ifikad16';
$db_name = 'if16_ingomagi';
$db_host = 'localhost';

$shipping_cost = 1.50; //shipping cost
$taxes = array( //List your Taxes percent here.
'VAT' => 0,
'Service Tax' => 0
);
//connect to MySql
$mysqli = new mysqli($db_host, $db_username, $db_password,$db_name);
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
?>
32 changes: 32 additions & 0 deletions Page/firma.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php require("../functions.php");
if (!isset($_SESSION["userId"])){
require("../header.php");
} else require ("../header2.php");
?>
<!DOCTYPE html>

<div class="container marketing">
<hr class="featurette-divider">

<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">Veini Projekt</h2>
<p class="lead">siia tuleb pikk seletus firmast ja selle tekkimisest ja ajaloost ja muust sellisest asjast.</p>

</div>
<div class="col-md-5">
<img class="featurette-image img-responsive center-block" src="../carousel/loodus.jpg" alt="Generic placeholder image">
</div>
</div>




<!-- /END THE FEATURETTES -->

</div><!-- /.container -->

</body>
</html>

<?php require("../footer.php");?>
131 changes: 131 additions & 0 deletions Page/frontpage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php
require("../functions.php");
if (!isset($_SESSION["userId"])){
require("../header.php");
} else require ("../header2.php");
?>

<!DOCTYPE html>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="../carousel/images.jpg" alt="First slide">
<div class="container">
<div class="carousel-caption">
<h1>Uus lehel?</h1>
<p>Soovite osta või müüa veine? registreerige kohe ja saate kohe hakata tellima meie suurepärasest veini valikust.</p>
<p><a class="btn btn-lg btn-primary" href="login.php" role="button">Sign up today</a></p>
</div>
</div>
</div>
<div class="item">
<img class="second-slide" src="../carousel/images2.jpg" alt="Second slide">
<div class="container">
<div class="carousel-caption">
<h1>valgete veinide valik</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="valged.php" role="button">Valged veinid</a></p>
</div>
</div>
</div>
<div class="item">
<img class="third-slide" src="../carousel/images.jpg" alt="Third slide">
<div class="container">
<div class="carousel-caption">
<h1>Punaste veinide valik</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="punased.php" role="button">Punased veinid</a></p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div><!-- /.carousel -->


<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->

<div class="container marketing">

<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-lg-4">
<img class="img-circle" src="../carousel/images.jpg" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna.</p>
<p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" src="../carousel/images.jpg" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.</p>
<p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" src="../carousel/images.jpg" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->


<!-- START THE FEATURETTES -->

<hr class="featurette-divider">

<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">First featurette heading. <span class="text-muted">It'll blow your mind.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<div class="col-md-5">
<img class="featurette-image img-responsive center-block" src="../carousel/images.jpg" alt="Generic placeholder image">
</div>
</div>

<hr class="featurette-divider">

<div class="row featurette">
<div class="col-md-7 col-md-push-5">
<h2 class="featurette-heading">Oh yeah, it's that good. <span class="text-muted">See for yourself.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<div class="col-md-5 col-md-pull-7">
<img class="featurette-image img-responsive center-block" src="../carousel/images.jpg" alt="Generic placeholder image">
</div>
</div>

<hr class="featurette-divider">

<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">And lastly, this one. <span class="text-muted">Checkmate.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<div class="col-md-5">
<img class="featurette-image img-responsive center-block" src="../carousel/images.jpg" alt="Generic placeholder image">
</div>
</div>




<?php require("../footer.php");?>
Binary file added Page/images/punane.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Page/images/valge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading