start connection to db and mail server
This commit is contained in:
parent
6a83944afe
commit
996d4c50dd
|
@ -1 +1,3 @@
|
||||||
.idea
|
.idea
|
||||||
|
config.ini.php
|
||||||
|
vendor
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"phpmailer/phpmailer": "^6.4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "d01b4a542231b112db557e6b7e5a5121",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "phpmailer/phpmailer",
|
||||||
|
"version": "v6.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||||
|
"reference": "050d430203105c27c30efd1dce7aa421ad882d01"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/050d430203105c27c30efd1dce7aa421ad882d01",
|
||||||
|
"reference": "050d430203105c27c30efd1dce7aa421ad882d01",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-ctype": "*",
|
||||||
|
"ext-filter": "*",
|
||||||
|
"ext-hash": "*",
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||||
|
"doctrine/annotations": "^1.2",
|
||||||
|
"phpcompatibility/php-compatibility": "^9.3.5",
|
||||||
|
"roave/security-advisories": "dev-latest",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5.6",
|
||||||
|
"yoast/phpunit-polyfills": "^0.2.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
|
||||||
|
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
|
||||||
|
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
|
||||||
|
"psr/log": "For optional PSR-3 debug logging",
|
||||||
|
"stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
|
||||||
|
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PHPMailer\\PHPMailer\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-2.1-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Marcus Bointon",
|
||||||
|
"email": "phpmailer@synchromedia.co.uk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jim Jagielski",
|
||||||
|
"email": "jimjag@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andy Prevost",
|
||||||
|
"email": "codeworxtech@users.sourceforge.net"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Brent R. Matzelle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||||
|
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/Synchro",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2021-03-31T20:06:42+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.0.0"
|
||||||
|
}
|
17
general.php
17
general.php
|
@ -1,16 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
function getConfig() {
|
||||||
|
return parse_ini_file('config.ini.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDatabase() {
|
||||||
|
$config = getConfig();
|
||||||
|
if($db = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], $config['db_database'])){
|
||||||
|
return $db;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function returnHeader() {
|
function returnHeader() {
|
||||||
?>
|
?>
|
||||||
<!Doctype html>
|
<!Doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<title>Alumni Max Emden</title>
|
<title>Alumni Max Emden</title>
|
||||||
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
|
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
|
||||||
<link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">
|
<link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
95
index.php
95
index.php
|
@ -3,41 +3,43 @@ require_once 'general.php';
|
||||||
|
|
||||||
returnHeader();
|
returnHeader();
|
||||||
|
|
||||||
|
$config = getConfig();
|
||||||
|
|
||||||
|
$minDate = date("m-d-Y", strtotime("-120 years"));
|
||||||
|
$maxDate = date("m-d-Y", strtotime("-10 years"));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="relative flex flex-wrap">
|
<div class="container">
|
||||||
<div class="w-full relative">
|
<div class="columns">
|
||||||
<div class="md:mt-6">
|
<div class="column col-2"></div>
|
||||||
<div class="hero container max-w-screen-lg mx-auto pb-10 flex justify-center">
|
<div class="column col-8">
|
||||||
<img src="https://max-emden.net/iserv/logo/logo.jpg" class="w-2/4" alt="Logo Max-Windmüller Gymnasium"/>
|
<div class="columns">
|
||||||
</div>
|
<div class="column col-2"></div>
|
||||||
<div class="text-center text-black font-semibold">
|
<div class="column col-8">
|
||||||
Beschreibender Text
|
<img class="img-responsive" src="<?php echo $config['logo_url'] ?>" alt="Logo Max-Windmüller Gymnasium"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="column col-2"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="submit.php" method="post" class="mt-8">
|
<p class="text-center"><?php echo $config['description'] ?></p>
|
||||||
<div class="mx-auto max-w-lg">
|
|
||||||
|
|
||||||
<div class="py-1">
|
<form action="submit.php" method="post">
|
||||||
<label class="px-1 text-sm text-gray-600" for="name">Name</label>
|
|
||||||
<input type="text" name="name" id="name" required class="text-md block px-3 py-2 rounded-lg w-full bg-white border-2
|
<div class="form-group">
|
||||||
border-gray-300 placeholder-gray-600
|
<label class="form-label" for="name">Name</label>
|
||||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
<input type="text" name="name" id="name" required="required" class="form-input">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="py-1">
|
<div class="form-group">
|
||||||
<label class="px-1 text-sm text-gray-600" for="email">E-Mail Adresse</label>
|
<label class="form-label" for="email">E-Mail Adresse</label>
|
||||||
<input type="email" name="email" id="email" required class="text-md block px-3 py-2 rounded-lg w-full bg-white border-2
|
<input type="email" name="email" id="email" required="required" class="form-input">
|
||||||
border-gray-300 placeholder-gray-600
|
|
||||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="py-1">
|
<div class="form-group">
|
||||||
<label class="px-1 text-sm text-gray-600" for="year">Jahrgang</label>
|
<label class="form-label" for="year">Abschlussjahrgang</label>
|
||||||
<select name="year" id="year" required class="text-md block px-3 py-2 rounded-lg w-full bg-white border-2
|
<select name="year" id="year" required="required" class="form-select">
|
||||||
border-gray-300 placeholder-gray-600
|
<option disabled="disabled" selected="selected" hidden="hidden">---</option>
|
||||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
|
||||||
<?php
|
<?php
|
||||||
for ($i = 1970; $i < date("Y"); $i++) {
|
for ($i = 1970; $i < date("Y"); $i++) {
|
||||||
?>
|
?>
|
||||||
|
@ -47,45 +49,36 @@ returnHeader();
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
<div class="py-1">
|
<label class="form-label" for="birthday">Geburtstag</label>
|
||||||
<label class="px-1 text-sm text-gray-600" for="birthday">Geburtstag</label>
|
<input type="date" name="birthday" id="birthday" required="required" pattern="\d{2}-\d{2}-\d{4} min="<?php echo $minDate ?>" max="<?php echo $maxDate ?>" class="form-input">
|
||||||
<input type="date" name="birthday" id="birthday" required class="text-md block px-3 py-2 rounded-lg w-full bg-white border-2
|
|
||||||
border-gray-300 placeholder-gray-600
|
|
||||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="py-1">
|
<div class="form-group">
|
||||||
<label class="px-1 text-sm text-gray-600" for="vocation">Tätigkeit</label>
|
<label class="form-label" for="vocation">Tätigkeit</label>
|
||||||
<textarea name="vocation" id="vocation" required class="text-md block px-3 py-2 rounded-lg w-full bg-white border-2
|
<textarea name="vocation" id="vocation" required="required" class="form-input">
|
||||||
border-gray-300 placeholder-gray-600
|
|
||||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-start">
|
<div class="form-group">
|
||||||
<label class="block text-gray-500 font-bold my-4 flex items-center">
|
<label class="form-checkbox">
|
||||||
<input class="leading-loose text-pink-600 top-0" type="checkbox" id="terms" name="terms" required/>
|
<input type="checkbox">
|
||||||
<span class="ml-2 text-sm py-2 text-gray-600 text-left">Ich akzeptiere hiermit
|
<i class="form-icon"></i>Ich akzeptiere hiermit<a
|
||||||
<a href="https://max-emden.de/wordpress/impressum/" target="_blank"
|
href="<?php echo $config['privacy_url'] ?>" target="_blank"
|
||||||
class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500">
|
class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500">
|
||||||
die Datenschutzerklärung.</a>
|
die Datenschutzerklärung.</a>
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="mt-3 text-lg font-semibold
|
<button type="submit" class="btn">Eintragen</button>
|
||||||
bg-gray-800 w-full text-white rounded-lg
|
|
||||||
px-6 py-3 block shadow-xl hover:text-white hover:bg-black" type="submit">
|
|
||||||
Eintragen
|
|
||||||
</button>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="column col-2"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,16 @@ returnHeader();
|
||||||
|
|
||||||
$file = file_get_contents("MOCK_DATA.json");
|
$file = file_get_contents("MOCK_DATA.json");
|
||||||
if ($file === false) {
|
if ($file === false) {
|
||||||
// deal with error...
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$entries = json_decode($file, true);
|
$entries = json_decode($file, true);
|
||||||
if ($entries === null) {
|
if ($entries === null) {
|
||||||
// deal with error...
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$config = getConfig();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
@ -37,6 +39,9 @@ if ($entries === null) {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//if ($_SERVER['REQUEST_METHOD'] != "POST") {
|
||||||
|
// die();
|
||||||
|
//}
|
||||||
|
|
||||||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
|
||||||
|
$config = getConfig();
|
||||||
|
|
||||||
|
$mail = new PHPMailer(true);
|
||||||
|
|
||||||
|
$mail->Host = $config['mail_server'];
|
||||||
|
$mail->Port = $config['mail_port'];
|
||||||
|
$mail->Username = $config['mail_user'];
|
||||||
|
$mail->Password = $config['mail_password'];
|
||||||
|
|
||||||
|
$mail->From = $config['mail_address'];
|
||||||
|
$mail->FromName = 'Mailer';
|
||||||
|
$mail->addAddress('test@joethei.de', 'Joe User');
|
||||||
|
|
||||||
|
$mail->Subject = 'Here is the subject';
|
||||||
|
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
!$mail->send();
|
||||||
|
} catch (\PHPMailer\PHPMailer\Exception $e) {
|
||||||
|
echo $e;
|
||||||
|
}
|
Loading…
Reference in New Issue