Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require_once "inc/package.inc.php";
- include "connect.php";
- //Ga er vanuit dat het formulier correct is ingevuld
- $correct = true;
- //Sla de waarden op in een variabel
- $title = $_POST['title'];
- if(isset($_POST['title']) && $_POST['title'] != ''){
- $title = filter_var($_POST['title'], FILTER_SANITIZE_STRING);
- $correct = true;
- } else {
- echo "<p id='popupr'>Geef een titel!</p>";
- $correct = false; //Toch een foute waarde, onthou dit!
- }
- $blog = $_POST['reactie'];
- if(isset($_POST['reactie']) && $_POST['reactie'] != ''){
- $blog = filter_var($_POST['reactie'], FILTER_SANITIZE_STRING);
- $correct = true;
- } else {
- $correct = false; //Toch een foute waarde, onthou dit!
- }
- $mobiel = $_POST['mobiel'];
- if(isset($_POST['mobiel']) && $_POST['mobiel'] != ''){
- $mobiel = filter_var($_POST['mobiel'], FILTER_SANITIZE_STRING);
- $correct = true;
- } else {
- $correct = false; //Toch een foute waarde, onthou dit!
- }
- $tweet = $_POST['hashtag'];
- if(isset($_POST['hashtag']) && $_POST['hashtag'] != ''){
- $blog = filter_var($_POST['hashtag'], FILTER_SANITIZE_STRING);
- $correct = true;
- } else {
- $correct = false; //Toch een foute waarde, onthou dit!
- }
- if(isset($_POST['btn_upload'])) {
- $img = $_FILES["file_img"];
- $filetmp = $_FILES["file_img"]["tmp_name"];
- $priority = 2;
- if (empty($img)) {
- $filename === null;
- $target === null;
- } else {
- $file = $_FILES["file_img"]["name"];
- $filetype = $_FILES["file_img"]["type"];
- // unieke toevoeging berekenen
- $uniqueId = uniqId();
- // een hash van het bestand, of data in bestand
- $hash = sha1_file($filetmp);
- $filename = "image_".$uniqueId."-".$hash.".png";
- $target = realPath("photo").DIRECTORY_SEPARATOR.$filename;
- move_uploaded_file($filetmp,$target);
- }
- $correct = true;
- }
- //Was alles correct ingevuld?
- if($correct){
- // voeg de reactie toe in de tabel blogs.
- $author = $_SESSION["name"];
- // voeg de reactie toe in de tabel blogs.
- include "datum.php";
- try{
- $stmt = $connection->prepare("INSERT INTO blogs(author, date, title, blog, mobiel, hashtag, priority, img_name, img_path) VALUES (:author, :date, :title, :blog, :mobiel, :hashtag, :priority, '$filename', '$target')");
- $stmt->bindValue(':author', $author);
- $stmt->bindValue(':date', $datum);
- $stmt->bindValue(':title', $title);
- $stmt->bindValue(':blog', $blog);
- $stmt->bindValue(':mobiel', $mobiel);
- $stmt->bindValue(':hashtag', $tweet);
- $stmt->bindValue(':priority', $priority);
- }
- catch(PDOException $e)
- {
- echo $e;
- }
- $result = $stmt->execute();
- if(!$result) {
- print_r($stmt->errorInfo());
- } else {
- header('Location: index.php');
- exit;
- }
- } else {
- //Er is ergens een foute waarde ingevoerd, geef de bezoeker de mogelijkheid om terug te gaan
- echo "<p>Er is een foute waarde ingevoerd, <a href="javascript:history.back();">ga terug</a>.</p>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement