storeEmail
This commit is contained in:
62
docs/contactEmails.sql
Normal file
62
docs/contactEmails.sql
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 5.2.0
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
|
--
|
||||||
|
-- Host: localhost
|
||||||
|
-- Erstellungszeit: 07. Feb 2023 um 14:51
|
||||||
|
-- Server-Version: 10.4.27-MariaDB
|
||||||
|
-- PHP-Version: 8.1.12
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
START TRANSACTION;
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Datenbank: `k200835_dog`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `contact_emails`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `contact_emails` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`dogs_id` int(11) NOT NULL,
|
||||||
|
`from_email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||||
|
`msg` varchar(1023) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||||
|
`created` timestamp NOT NULL DEFAULT current_timestamp()
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes der exportierten Tabellen
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `contact_emails`
|
||||||
|
--
|
||||||
|
ALTER TABLE `contact_emails`
|
||||||
|
ADD PRIMARY KEY (`id`),
|
||||||
|
ADD KEY `FK_dogs_id` (`dogs_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für exportierte Tabellen
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `contact_emails`
|
||||||
|
--
|
||||||
|
ALTER TABLE `contact_emails`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints der exportierten Tabellen
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints der Tabelle `contact_emails`
|
||||||
|
--
|
||||||
|
ALTER TABLE `contact_emails`
|
||||||
|
ADD CONSTRAINT `FK_dogs_id` FOREIGN KEY (`dogs_id`) REFERENCES `dogs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
COMMIT;
|
||||||
@ -120,4 +120,35 @@ function getNewFilename($targetDir, $fileExt, $length)
|
|||||||
return $newFname .".".$fileExt;
|
return $newFname .".".$fileExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDogByQrId($qr_id, $conn, $fields = null)
|
||||||
|
{
|
||||||
|
if(strcmp($qr_id, 'SESS') === 0)
|
||||||
|
{
|
||||||
|
$allHeaders = getallheaders();
|
||||||
|
$auth = new Auth($conn, $allHeaders);
|
||||||
|
$data = json_decode($auth->isValid());
|
||||||
|
$user = $data->data;
|
||||||
|
$qr_id = $user->qr_id;
|
||||||
|
}
|
||||||
|
$fetch_user_qr_id =
|
||||||
|
"SELECT id, qr_id, email, name, phone,
|
||||||
|
qr_width_cm, qr_height_cm, qr_fontsize, qr_visible_items, qr_item_sequence,
|
||||||
|
qr_code, picture FROM `dogs` WHERE `qr_id`=:qr_id";
|
||||||
|
$query_stmt = $conn->prepare($fetch_user_qr_id);
|
||||||
|
$query_stmt->bindValue(':qr_id', $qr_id,PDO::PARAM_STR);
|
||||||
|
$query_stmt->execute();
|
||||||
|
|
||||||
|
// IF THE dog IS FOUNDED BY qr_id
|
||||||
|
if($query_stmt->rowCount())
|
||||||
|
{
|
||||||
|
$row = $query_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$returnData = new CMsg(1,200,'get dog',$fields,$row);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$returnData = new CMsg(0,422,'no dog',$fields);
|
||||||
|
}
|
||||||
|
return $returnData;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -73,6 +73,7 @@ try
|
|||||||
if($ret)
|
if($ret)
|
||||||
{
|
{
|
||||||
$result = new CMsg(1, 200, "Email send successfully.");
|
$result = new CMsg(1, 200, "Email send successfully.");
|
||||||
|
$storeResult = storeEmail();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -85,4 +86,20 @@ catch (Exception $e)
|
|||||||
$result = new CMsg(0, 500, $e->getMessage() );
|
$result = new CMsg(0, 500, $e->getMessage() );
|
||||||
echo $result->jsonarray();
|
echo $result->jsonarray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function storeEmail()
|
||||||
|
{
|
||||||
|
global $qr_id, $conn, $msg, $fromEmail;
|
||||||
|
|
||||||
|
$dogRes = getDogByQrId($qr_id, $conn);
|
||||||
|
|
||||||
|
if($dogRes->success)
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO contact_email (dogs_id, from_email, msg) VALUES (?,?,?)";
|
||||||
|
$conn->prepare($sql)->execute([$dogRes->data->id, $fromEmail, $msg]); // throw PDO::exception when failed
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dogRes;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@ -42,32 +42,7 @@ else
|
|||||||
$qr_id = trim($data->qr_id);
|
$qr_id = trim($data->qr_id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(strcmp($qr_id, 'SESS') === 0)
|
$returnData = getDogByQrId($qr_id, $conn, $fields);
|
||||||
{
|
|
||||||
$allHeaders = getallheaders();
|
|
||||||
$auth = new Auth($conn, $allHeaders);
|
|
||||||
$data = json_decode($auth->isValid());
|
|
||||||
$user = $data->data;
|
|
||||||
$qr_id = $user->qr_id;
|
|
||||||
}
|
|
||||||
$fetch_user_qr_id =
|
|
||||||
"SELECT id, qr_id, email, name, phone,
|
|
||||||
qr_width_cm, qr_height_cm, qr_fontsize, qr_visible_items, qr_item_sequence,
|
|
||||||
qr_code, picture FROM `dogs` WHERE `qr_id`=:qr_id";
|
|
||||||
$query_stmt = $conn->prepare($fetch_user_qr_id);
|
|
||||||
$query_stmt->bindValue(':qr_id', $qr_id,PDO::PARAM_STR);
|
|
||||||
$query_stmt->execute();
|
|
||||||
|
|
||||||
// IF THE dog IS FOUNDED BY qr_id
|
|
||||||
if($query_stmt->rowCount())
|
|
||||||
{
|
|
||||||
$row = $query_stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$returnData = new CMsg(1,200,'get dog',$fields,$row);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$returnData = new CMsg(0,422,'no dog',$fields);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(PDOException $e)
|
catch(PDOException $e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,30 +1,37 @@
|
|||||||
/* Style inputs, select elements and textareas */
|
/* Style inputs, select elements and textareas */
|
||||||
input[type=email], select, textarea{
|
.contactInput
|
||||||
|
input[type=email], select, textarea
|
||||||
|
{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
background-color: #f26e0a;
|
background-color: white;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
.formForm input[type=submit]
|
||||||
|
{
|
||||||
background-color: #aa0404;
|
background-color: #aa0404;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 6px 10px;
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 50%;
|
width: auto;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.flexCenter
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
/* Style the label to display next to the inputs */
|
/* Style the label to display next to the inputs */
|
||||||
label
|
.flexCenter label
|
||||||
{
|
{
|
||||||
|
margin-left: 0;
|
||||||
padding: 2px 12px 2px 0;
|
padding: 2px 12px 2px 0;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
@ -34,6 +41,8 @@ input[type=submit] {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
}
|
}
|
||||||
.containerForm
|
.containerForm
|
||||||
{
|
{
|
||||||
@ -43,30 +52,31 @@ input[type=submit] {
|
|||||||
background-color: #f6602e;
|
background-color: #f6602e;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 400px;
|
width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formForm
|
.formForm
|
||||||
{
|
{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-width: 600px;
|
width: 100%;
|
||||||
|
align-items: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Floating column for labels: 25% width */
|
/* Floating column for labels: 25% width */
|
||||||
.col-25
|
.col-30
|
||||||
{
|
{
|
||||||
float: left;
|
float: left;
|
||||||
width: 25%;
|
width: 30%;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Floating column for inputs: 75% width */
|
/* Floating column for inputs: 75% width */
|
||||||
.col-75
|
.col-70
|
||||||
{
|
{
|
||||||
float: left;
|
float: left;
|
||||||
width: 75%;
|
width: 70%;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +85,7 @@ input[type=submit] {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
|||||||
@ -1,60 +0,0 @@
|
|||||||
/* Style inputs, select elements and textareas */
|
|
||||||
|
|
||||||
/* Style the label to display next to the inputs */
|
|
||||||
label
|
|
||||||
{
|
|
||||||
padding: 12px 12px 12px 0;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.formForm
|
|
||||||
{
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
}
|
|
||||||
/* Style the container */
|
|
||||||
.containerForm
|
|
||||||
{
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
padding: 20px;
|
|
||||||
width: 600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Floating column for labels: 25% width */
|
|
||||||
.col-25
|
|
||||||
{
|
|
||||||
float: left;
|
|
||||||
width: 25%;
|
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Floating column for inputs: 75% width */
|
|
||||||
.col-75
|
|
||||||
{
|
|
||||||
float: left;
|
|
||||||
width: 75%;
|
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rowForm
|
|
||||||
{
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row
|
|
||||||
{
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.textArea
|
|
||||||
{
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -81,28 +81,30 @@ const data = {
|
|||||||
<div className="containerForm">
|
<div className="containerForm">
|
||||||
<Toaster toastOptions={{ position: "top-center" }} />
|
<Toaster toastOptions={{ position: "top-center" }} />
|
||||||
<form className="formForm" id='idForm' onSubmit={submitForm}>
|
<form className="formForm" id='idForm' onSubmit={submitForm}>
|
||||||
<p>Bitte schreib eine Email:</p>
|
|
||||||
<div className="rowForm">
|
<div className="rowForm">
|
||||||
<div className="col-25">
|
<div>Bitte schreib eine Email:</div><div></div>
|
||||||
|
</div>
|
||||||
|
<div className="rowForm">
|
||||||
|
<div className="col-30">
|
||||||
<label htmlFor="email">Email</label>
|
<label htmlFor="email">Email</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-75">
|
<div className="col-70">
|
||||||
<input type="email" id="fromEmail" name="fromEmail" placeholder="Deine Email.." onChange={onChangeInput} required />
|
<input type="email" id="fromEmail" name="fromEmail" placeholder="Deine Email.." onChange={onChangeInput} required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowForm">
|
<div className="rowForm">
|
||||||
<div className="col-25">
|
<div className="col-30">
|
||||||
<label>An</label>
|
<label>An</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-75">
|
<div className="col-70">
|
||||||
<label>{toEmail}</label>
|
<label>{toEmail}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowForm">
|
<div className="rowForm">
|
||||||
<div className="col-25">
|
<div className="col-30">
|
||||||
<label htmlFor="msg">Nachricht</label>
|
<label htmlFor="msg">Nachricht</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-75">
|
<div className="col-70">
|
||||||
<textarea className="textArea" id="msg" name="msg" placeholder={`Ich habe ${name} gefunden! Bitte rufen Sie mich an, Telefon:(bitte angeben...)`} onChange={onChangeInputTextArea} required/>
|
<textarea className="textArea" id="msg" name="msg" placeholder={`Ich habe ${name} gefunden! Bitte rufen Sie mich an, Telefon:(bitte angeben...)`} onChange={onChangeInputTextArea} required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,27 +10,35 @@
|
|||||||
<div class="containerForm">
|
<div class="containerForm">
|
||||||
<div style="position: fixed; z-index: 9999; inset: 16px; pointer-events: none;"></div>
|
<div style="position: fixed; z-index: 9999; inset: 16px; pointer-events: none;"></div>
|
||||||
<form class="formForm" id="idForm">
|
<form class="formForm" id="idForm">
|
||||||
<p>Bitte schreib eine Email:</p>
|
|
||||||
<div class="rowForm">
|
<div class="rowForm">
|
||||||
<div class="col-25"><label for="email">Email</label></div>
|
<p>Bitte schreib eine Email:</p>
|
||||||
<div class="col-75"><input type="email" id="fromEmail" name="fromEmail" placeholder="Deine Email.."
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="rowForm">
|
||||||
|
<div class="col-30"><label for="email">Email</label></div>
|
||||||
|
<div class="col-70"><input class='contactInput' type="email" id="fromEmail" name="fromEmail" placeholder="Deine Email.."
|
||||||
required=""></div>
|
required=""></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rowForm">
|
<div class="rowForm">
|
||||||
<div class="col-25">
|
<div class="col-30">
|
||||||
<label>An</label>
|
<label>An</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-75">
|
<div class="col-70">
|
||||||
<label>a@q.q</label>
|
<label>a@q.q</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rowForm">
|
<div class="rowForm">
|
||||||
<div class="col-25"><label for="msg">Nachricht</label></div>
|
<div class="col-30"><label for="msg">Nachricht</label></div>
|
||||||
<div class="col-75"><textarea class="textArea" id="msg" name="msg"
|
<div class="col-70"><textarea class="textArea" id="msg" name="msg"
|
||||||
placeholder="Ich habe Ursula gefunden! Bitte rufen Sie mich an, Telefon:(bitte angeben...)"
|
placeholder="Ich habe Ursula gefunden! Bitte rufen Sie mich an, Telefon:(bitte angeben...)"
|
||||||
required=""></textarea></div>
|
required=""></textarea></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rowForm"><input type="submit" value="Nachricht senden!"></div>
|
<div class="rowForm">
|
||||||
|
<div></div>
|
||||||
|
<input class='contactInput' type="submit" value="Nachricht senden!">
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user