/users/patterns/www/editNews.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
    
    $Datum 
$_POST[Datum];
    
$NewsDE$_POST[NewsDE];
    
$NewsEN$_POST[NewsEN];
    
$Name$_POST[Name];
    
$Link$_POST[Link];
    
$File$_FILES['datei']['name'];
    
    if(
$Datum ==''){
            echo 
'<p><h1 align="center"><font color="#FB0514">Achtung! Datum eingeben!</font></h1></p>';
            echo 
'<p align="center"><button onclick="history.go(-1);">Zur&uuml;ck</button></p>';
    } else {
        

    include 
'./schnitte/login.php';
    
    
// Create connection
$conn = new mysqli($server$user$passwort$datenbank);
mysqli_query($conn"SET NAMES 'utf8'");
 
// Check connection
 
if ($conn->connect_error) {
     die(
"Connection failed: " $conn->connect_error);


    
    
$sql "INSERT INTO News (Datum, NewsDE, NewsEN, Name, Link) VALUES ('$Datum', '$NewsDE', '$NewsEN', '$Name', '$File')";

if (
$conn->query($sql) === TRUE) {
    echo 
'<p><h1 align="center"><font color="#00FF00">Datensatz erfolgreich in Datenbank gespeichert</font></h1></p>';
    echo 
'<p align="center"><button onclick="history.go(-1);">Zur&uuml;ck</button></p>';
} else {
    echo 
"Error: " $sql "<br>" $conn->error;
}

$conn->close();
        if(
$File != ''){
        
move_uploaded_file($_FILES['datei']['tmp_name'], 'img_news/'.$_FILES['datei']['name']);
        }
    }
?>