Sorry wegen dem Code.Ist leider etwas verschoben.
Antwort
Antwort
Sorry, wegen der Formatierung des Codes.Es geht leider nicht anderst.
Antwort
Main.java
https://gist.github.com/PROPHP17/d3e598bb4ad7ed18a19a2fb718ec01d2
Sample.fxml
https://gist.github.com/PROPHP17/0098e39d5d55f59e16ec07ffb1265a00
Antwort
Fehlermeldungen:
File is an image - image/jpeg.
Warning: move_uploaded_file(uploads/catzu.jpg) [function.move-uploaded-file.php]: failed to open stream: No such file or directory in /home/phppro/www/www.phppro.ch/upload.php on line 38
Warning: move_uploaded_file() [function.move-uploaded-file.php]: Unable to move '/tmp/php8tsBqX' to 'uploads/catzu.jpg' in /home/phppro/wwwwww.phppro.ch/upload.phppp on line 38
Sorry, there was an error uploading your file.
Antwort
CODE:
<?php
session_start();
$pdo = new PDO('mysql:host=localhost;dbname=datenbankname', 'benutzername', 'passwort');
?>
<?php
function random_string() {
if(function_exists('random_bytes')) {
$bytes = random_bytes(16);
$str = bin2hex($bytes);
} else if(function_exists('openssl_random_pseudo_bytes')) {
$bytes = openssl_random_pseudo_bytes(16);
$str = bin2hex($bytes);
} else if(function_exists('mcrypt_create_iv')) {
$bytes = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
$str = bin2hex($bytes);
} else {
//Bitte euer_geheim_string durch einen zufälligen String mit >12 Zeichen austauschen
$str = md5(uniqid('meinstring', true));
}
return $str;
}
if(!isset($_SESSION['userid'])) {
die('Bitte zuerst <a href="login.php">einloggen</a>');
}
$showForm = true;
if(!isset($_POST['email']) || empty($_POST['email'])) {
$error = "<b>Bitte eine E-Mail-Adresse eintragen</b>";
} else {
$sql = "SELECT betreff FROM email";
foreach ($pdo->query($sql) as $row) {
$row['betreff'];
}
$tex = "SELECT text FROM email";
foreach ($pdo->query($tex) as $row1) {
$row1['text'];
}
$statement = $pdo->prepare("SELECT * FROM newsletter1 WHERE email = :email");
$result = $statement->execute(array('email' => $_POST['email']));
$user = $statement->fetch();
$empfaenger = $user['email'];
$betreff = $row['betreff'];
$datei = $dateien = array($_FILES['datei_feld']['tmp_name'] => $_FILES['datei_feld']['name']);;
$from = "From: meinefirma <meine@email.de>";
$text = $row1['text'];
mail($empfaenger, $betreff, $text, $from, $dateien);
echo "Emails erfolgreich gesendet<br><br>";
echo "<a href='www.firma.de'>Zurück zur Startseite</a>";
$showForm = false;
}
if($showForm):
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Concert+One" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /><title>Senden</title>
</head>
<body>
<div id="webseite">
<div id="header">
<img src="LOGO.png" height="133" width="268" alt="meinlogo">
</div>
<div id="main">
<div id="inhalt">
<h2>Senden</h2>
<form action="?send=1" method="post" enctype="multipart/form-data">
Email:<br>
<input type="email" name="email" value="<?php echo isset($_POST['email']) ? htmlentities($_POST['email']) : ''; ?>"><br><br>
<input name="datei_feld"type="file" size="50" accept="pdf/text/jpg/png/bmp"><br> </label>
<input type="submit" value="Senden" class="button">
</form>
</div>
<?php
endif;
?>
</div>
<div id="footer">
<p>©2018 by firma</p>
</div>
</div>
</div>
<script>
</script>
</body>
</html>
Antwort
<?php
session_start();
$pdo = new PDO('mysql:host=meinhost;dbname=datenbankname', 'benutzer', 'passwort');
?>
<?php
function random_string() {
if(function_exists('random_bytes')) {
$bytes = random_bytes(16);
$str = bin2hex($bytes);
} else if(function_exists('openssl_random_pseudo_bytes')) {
$bytes = openssl_random_pseudo_bytes(16);
$str = bin2hex($bytes);
} else if(function_exists('mcrypt_create_iv')) {
$bytes = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
$str = bin2hex($bytes);
} else {
mit >12 Zeichen austauschen
$str = md5(uniqid('mein string', true));
}
return $str;
}
if(!isset($_SESSION['userid'])) {
die('Bitte zuerst <a href="Login.php">einloggen</a>');
}
$showForm = true;
if(!isset($_POST['email']) || empty($_POST['email'])) {
$error = "<b>Bitte Email-adresse auswählen</b>";
} else {
$statement = $pdo->prepare("SELECT * FROM newsletter1 WHERE email = :email");
$result = $statement->execute(array('email' => $_POST['email']));
$user = $statement->fetch();
$empfaenger = $user['email'];
$betreff = "BETREFF XY";
$from = "From: Firma <test@test.ch>";
$text = $user['text'];
mail($empfaenger, $betreff, $text, $from);
echo "Email wurde gesendet.<br><br>";
echo "<a href='Login.php'>Zurück zum Login</a>";
$showForm = false;
}
if($showForm):
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Concert+One" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /><title>Email</title>
<link rel="stylesheet" type="text/css" href="designp.css">
</head>
<body>
<div id="webseite">
<div id="header">
<img src="LOGO.png" height="133" width="268" alt="mein-logo">
</div>
<div id="main">
<div id="inhalt">
<h2>Email schreiben</h2>
<div id="schreiben">
<?php
if(isset($error) && !empty($error)) {
echo $error;
}
?>
<form action="?send=1" method="post">
E-Mail:<br>
<input type="email" name="email" value="<?php echo isset($_POST['email']) ? htmlentities($_POST['email']) : ''; ?>"><br><br>
Text:<br>
<textarea id="text" name="text1" cols="35" rows="4"></textarea> <br><br>
<input type="submit" value="Senden" class="button">
</form>
</div>
<?php
endif; //Endif von if($showForm)
?>
</div>
<div id="footer">
<p>©2018 by xy</p>
</div>
</div>
</div>
<script>
</script>
</body>
</html>
Antwort
CODE:
<?php
include(“config.php”);
// Verbindung zur Datenbank via PDO aufbauen
try {
$conn = new PDO("mysql:host=$PDO_HOST;dbname=$PDO_DATABASE", $PDO_USER, $PDO_PASS);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec("set names utf8");
}
catch(PDOException $e)
{
echo "Connection to Database failed! " . $e->getMessage();
exit;
}
$email = $_POST ['email'] ? null;
if(isset($_POST['submit'])){
//Datenbankeintraege die zu der E-Mail passen aufzaehlen
$statement = $conn->prepare("SELECT COUNT(*) as Anzahl FROM newsletter1 WHERE email = :email");
$result = $statement->execute(array('email' => $email));
$user = $statement->fetch();
//Pruefen ob es diese E-Mail in der Datenbank gibt
if($user['Anzahl'] == 0)
{
$errorMessage = '<font color="red">Fehler: Diese E-Mail ist in der Datenbank nicht vorhanden!</font><br><br>';
} else {
$mail = '<font color="green">Die E-Mail-Adresse wurde aus dem Newsletter gelöscht!</font>';
}
}
//Formularausgabe definieren
$formular = '<div id="Z">
<form action="email.php" method="post">
Bitte E-Mail eingeben:<br>
<input type="email" name="email"><br><br>
<input type="submit" value="Abmelden" name="submit" class="button">';
echo '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<lhttps://fonts.googleapis.com/css?family=Concert+Oneoncert+One" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /><title>Newsletter abmelden</title>
</head>
<body>
<div id="webseite">
<div id="header">
<img src="Logo.jpg" height="133" width="268" alt="mein-logo">
</div>
<div id="main">
<div id="inhalt">
<h2>Newsletter abmelden</h2>';
if(isset($errorMessage)) {
//Bei einem Fehler die Fehlermeldung und das Formular erneut ausgeben
echo $errorMessage;
echo $formular;
} elseif(isset($mail)) {
//Wenn die Mail vorhanden ist folgt hier die Loeschung aus der Datenbank
echo $mail;
$stmt = $conn->prepare("DELETE FROM newsletter1 WHERE email = :email");
$stmt_result = $stmt->execute(array('email' => $email));
} else {
//Falls noch kein Aufruf getaetigt wurde das Formular einbinden
echo $formular;
}
echo'</form>
</div>
</div>
<div id="footer">
<p>©2018 by xy</p>
</div>
</div>
</div>
<script>
</script>
</body>
</html>';
?>