start connection to db and mail server
This commit is contained in:
parent
6a83944afe
commit
996d4c50dd
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
||||
.idea
|
||||
.idea
|
||||
config.ini.php
|
||||
vendor
|
5
composer.json
Normal file
5
composer.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"phpmailer/phpmailer": "^6.4"
|
||||
}
|
||||
}
|
95
composer.lock
generated
Normal file
95
composer.lock
generated
Normal file
@ -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
|
||||
|
||||
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() {
|
||||
?>
|
||||
<!Doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<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">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
133
index.php
133
index.php
@ -3,89 +3,82 @@ require_once 'general.php';
|
||||
|
||||
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="w-full relative">
|
||||
<div class="md:mt-6">
|
||||
<div class="hero container max-w-screen-lg mx-auto pb-10 flex justify-center">
|
||||
<img src="https://max-emden.net/iserv/logo/logo.jpg" class="w-2/4" alt="Logo Max-Windmüller Gymnasium"/>
|
||||
</div>
|
||||
<div class="text-center text-black font-semibold">
|
||||
Beschreibender Text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="submit.php" method="post" class="mt-8">
|
||||
<div class="mx-auto max-w-lg">
|
||||
|
||||
<div class="py-1">
|
||||
<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
|
||||
border-gray-300 placeholder-gray-600
|
||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="column col-2"></div>
|
||||
<div class="column col-8">
|
||||
<div class="columns">
|
||||
<div class="column col-2"></div>
|
||||
<div class="column col-8">
|
||||
<img class="img-responsive" src="<?php echo $config['logo_url'] ?>" alt="Logo Max-Windmüller Gymnasium"/>
|
||||
</div>
|
||||
<div class="column col-2"></div>
|
||||
</div>
|
||||
|
||||
<div class="py-1">
|
||||
<label class="px-1 text-sm text-gray-600" 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
|
||||
border-gray-300 placeholder-gray-600
|
||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
||||
</div>
|
||||
<p class="text-center"><?php echo $config['description'] ?></p>
|
||||
|
||||
<div class="py-1">
|
||||
<label class="px-1 text-sm text-gray-600" for="year">Jahrgang</label>
|
||||
<select name="year" id="year" 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">
|
||||
<?php
|
||||
for ($i = 1970; $i < date("Y"); $i++) {
|
||||
?>
|
||||
<option><?php echo $i ?></option>
|
||||
<form action="submit.php" method="post">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="name">Name</label>
|
||||
<input type="text" name="name" id="name" required="required" class="form-input">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="email">E-Mail Adresse</label>
|
||||
<input type="email" name="email" id="email" required="required" class="form-input">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="year">Abschlussjahrgang</label>
|
||||
<select name="year" id="year" required="required" class="form-select">
|
||||
<option disabled="disabled" selected="selected" hidden="hidden">---</option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
for ($i = 1970; $i < date("Y"); $i++) {
|
||||
?>
|
||||
<option><?php echo $i ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" 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">
|
||||
</div>
|
||||
|
||||
<div class="py-1">
|
||||
<label class="px-1 text-sm text-gray-600" for="birthday">Geburtstag</label>
|
||||
<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 class="py-1">
|
||||
<label class="px-1 text-sm text-gray-600" 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
|
||||
border-gray-300 placeholder-gray-600
|
||||
shadow-md focus:placeholder-gray-500 focus:bg-white focus:border-gray-600 focus:outline-none">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="vocation">Tätigkeit</label>
|
||||
<textarea name="vocation" id="vocation" required="required" class="form-input">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-start">
|
||||
<label class="block text-gray-500 font-bold my-4 flex items-center">
|
||||
<input class="leading-loose text-pink-600 top-0" type="checkbox" id="terms" name="terms" required/>
|
||||
<span class="ml-2 text-sm py-2 text-gray-600 text-left">Ich akzeptiere hiermit
|
||||
<a href="https://max-emden.de/wordpress/impressum/" target="_blank"
|
||||
class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500">
|
||||
die Datenschutzerklärung.</a>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-checkbox">
|
||||
<input type="checkbox">
|
||||
<i class="form-icon"></i>Ich akzeptiere hiermit<a
|
||||
href="<?php echo $config['privacy_url'] ?>" target="_blank"
|
||||
class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500">
|
||||
die Datenschutzerklärung.</a>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="mt-3 text-lg font-semibold
|
||||
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>
|
||||
<button type="submit" class="btn">Eintragen</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div class="column col-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<?php
|
||||
|
||||
|
@ -5,14 +5,16 @@ returnHeader();
|
||||
|
||||
$file = file_get_contents("MOCK_DATA.json");
|
||||
if ($file === false) {
|
||||
// deal with error...
|
||||
die();
|
||||
}
|
||||
|
||||
$entries = json_decode($file, true);
|
||||
if ($entries === null) {
|
||||
// deal with error...
|
||||
die();
|
||||
}
|
||||
|
||||
$config = getConfig();
|
||||
|
||||
?>
|
||||
|
||||
<div class="flex flex-col">
|
||||
@ -37,6 +39,9 @@ if ($entries === null) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
?>
|
||||
<tr>
|
||||
|
30
submit.php
Normal file
30
submit.php
Normal file
@ -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
Block a user