From 1f6cca7d69daa88f00d3b9f873b2fb10ce021e70 Mon Sep 17 00:00:00 2001 From: gvalgerist Date: Mon, 19 Jun 2017 03:36:45 +0300 Subject: [PATCH] Add files via upload --- edit.php | 55 ++++++++++ functions.php | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++ loginpb.php | 160 +++++++++++++++++++++++++++++ movies.php | 132 ++++++++++++++++++++++++ 4 files changed, 627 insertions(+) create mode 100644 edit.php create mode 100644 functions.php create mode 100644 loginpb.php create mode 100644 movies.php diff --git a/edit.php b/edit.php new file mode 100644 index 0000000..2c05a5d --- /dev/null +++ b/edit.php @@ -0,0 +1,55 @@ + + +

+ tagasi + +

Muuda kirjet

+
" method="post" > +
+

+
+ " > +

+
+

+
+

+ + +


+ +
diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..0b78629 --- /dev/null +++ b/functions.php @@ -0,0 +1,280 @@ +prepare("INSERT INTO eksam(email, password) VALUES(?, ?)"); + + echo $mysqli->error; + + $stmt->bind_param("ss", $email, $password); + + if($stmt->execute()) { + + echo "salvestamine onnestus"; + + } else { + + echo "ERROR".$stmt->error; + } + + $stmt->close(); + $mysqli->close(); + + } + + function login($email, $password) { + + $error=""; + + $database = "if16_georg"; + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + $stmt = $mysqli->prepare("SELECT id, email, password FROM eksam WHERE email=?"); + + echo $mysqli->error; + + $stmt->bind_param("s", $email); + + $stmt->bind_result($id, $emailFromDb,$passwordFromDb); + + $stmt->execute(); + + if($stmt->fetch()){ + + $hash=hash("sha512", $password); + if($hash==$passwordFromDb){ + + echo"Kasutaja logis sisse ".$id; + + $_SESSION["userId"]=$id; + $_SESSION["userEmail"]=$emailFromDb; + + header("Location: movies.php"); + + }else { + $error="vale parool"; + } + + }else{ + + $error="ei ole sellist emaili"; + + } + + return $error; + + } + + function savecontact ($nimi, $staatus, $kuup, $user) { + + $database = "if16_georg"; + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + $stmt = $mysqli->prepare("INSERT INTO filmid(nimi, staatus, kuup, kasutaja) VALUES(?, ?, ?, ?)"); + + echo $mysqli->error; + + $stmt->bind_param("ssss", $nimi, $staatus, $kuup, $user); + + if($stmt->execute()) { + + echo "salvestamine onnestus"; + + } else { + + echo "ERROR".$stmt->error; + } + + $stmt->close(); + $mysqli->close(); + + } + + function getallcontacts($user, $q, $sort, $direction) { + + $allowedSortOptions=["nimi","staatus","kuup","reiting"]; + if(!in_array($sort, $allowedSortOptions)){ + $sort = "nimi"; + } + + + $orderBy="ASC"; + if($direction == "descending"){ + $orderBy="DESC"; + } + + + + $database = "if16_georg"; + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + if($q==""){ + + $stmt=$mysqli->prepare(" + SELECT nimi, staatus, kuup, reiting + FROM filmid + WHERE kasutaja = ? + ORDER BY $sort $orderBy + "); + + $stmt->bind_param("s", $user); + + } else { + + $searchword="%".$q."%"; + $stmt=$mysqli->prepare(" + SELECT nimi, staatus, kuup, reiting + FROM filmid + WHERE kasutaja = ? AND (nimi LIKE ? OR staatus LIKE ? OR kuup LIKE ? OR reiting LIKE ?) + ORDER BY $sort $orderBy + "); + + $stmt->bind_param("sssss", $user, $searchword, $searchword, $searchword, $searchword); + + } + + + $stmt->bind_result($nimi, $staatus, $kuup, $reiting); + $stmt->execute(); + + $result=array(); + + while($stmt->fetch()) { + + $contact= new stdclass(); + + $contact->nimi=$nimi; + $contact->staatus=$staatus; + $contact->kuup=$kuup; + $contact->reiting=$reiting; + + + array_push($result, $contact); + } + + $stmt->close(); + $mysqli->close(); + + return $result; + } + + function getSingleContactData($nimi){ + + $database = "if16_georg"; + + + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + $stmt = $mysqli->prepare("SELECT staatus, kuup, reiting FROM filmid WHERE nimi=?"); + $stmt->bind_param("s", $nimi); + $stmt->bind_result($staatus, $kuup, $reiting); + $stmt->execute(); + + + $contact = new Stdclass(); + + + if($stmt->fetch()){ + + $contact->nimi = $nimi; + $contact->staatus = $staatus; + $contact->kuup = $kuup; + $contact->reiting = $reiting; + + + }else{ + + header("Location: functions.php"); + exit(); + } + + $stmt->close(); + $mysqli->close(); + + return $contact; + + } + function updatecontact($nimi, $staatus, $kuup, $uusnimi, $reiting){ + + $database = "if16_georg"; + + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + $stmt = $mysqli->prepare("UPDATE filmid SET nimi=?, staatus=?, kuup=?, reiting=? WHERE nimi=?"); + $stmt->bind_param("sssss",$uusnimi, $staatus, $kuup, $reiting, $nimi); + + // kas õnnestus salvestada + if($stmt->execute()){ + + echo "salvestus õnnestus!"; + } + + $stmt->close(); + $mysqli->close(); + + } + + function deletecontact($nimi){ + + $database = "if16_georg"; + + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + $stmt = $mysqli->prepare("DELETE FROM filmid WHERE nimi=?"); + $stmt->bind_param("s", $nimi); + + + if($stmt->execute()){ + + } + + $stmt->close(); + $mysqli->close(); + + } + + + + function getStaatus($user) { + + $database = "if16_georg"; + $mysqli = new mysqli($GLOBALS["serverHost"], $GLOBALS["serverUsername"], $GLOBALS["serverPassword"], $database); + + + $stmt=$mysqli->prepare(" SELECT COUNT(staatus) FROM filmid WHERE kasutaja = ? AND (staatus LIKE 'vaadatud'); "); + + $stmt->bind_param("s", $user); + + + $stmt->bind_result($vaadatud); + $stmt->execute(); + + if($stmt->execute()){ + echo "korras"; + echo $vaadatud; + } + + + $stmt->close(); + $mysqli->close(); + + + + } + + + + + + + + + + +?> \ No newline at end of file diff --git a/loginpb.php b/loginpb.php new file mode 100644 index 0000000..2f48209 --- /dev/null +++ b/loginpb.php @@ -0,0 +1,160 @@ + + + +

Logi sisse

+
+
+ + +

+ + +

+ + +
+ +

Loo Kasutaja

+Tärniga väljad on kohustuslikud +
+ +
+
+ +

+ +
+ +

+ +
+ +

+ + + + +



+ +
\ No newline at end of file diff --git a/movies.php b/movies.php new file mode 100644 index 0000000..813cc4d --- /dev/null +++ b/movies.php @@ -0,0 +1,132 @@ + +

Filmide märkmik

+ +

+ Tere tulemast + Logi valja + +

+

Salvesta uus film

+
+
+

+ +
+

+ +
+ + +

+ +
+ + Vaadatud:
+ +

Filmid

+
+ +

+
+"; + + $html .= ""; + $html .= "Nimi"; + $html .= "Staatus"; + $html .= "Kuupaev"; + $html .= "Reiting"; + $html .= ""; + + foreach($contactdata as $c) { + + + $html .= ""; + $html .= "".$c->nimi.""; + $html .= "".$c->staatus.""; + $html .= "".$c->kuup.""; + $html .= "".$c->reiting.""; + $html .= "Muuda"; + $html .= ""; + + } + + $html .= ""; + + echo $html; + + +?> + + + + + + + \ No newline at end of file