Я делаю очень простую форму HTML, используя PHP. Я хочу, чтобы форма была выполнена:
- Ввод электронной почты пользователю (выполнено)
- Экспорт в базу данных SQL (у меня настроена база данных)
- Показывать ввод на странице и иметь возможность загружать результаты как .csv и .pdf
Другой вопрос, что лучше всего:
- Иметь расширение. php файл, загруженный на FTP-сервер (или)
- Записать сценарий php в HTML файл?
Наконец, было бы проще написать php вместо Python?
Вот код php:
<?php
$date = $_POST['date'];
$client = $_POST['client'];
$session = $_POST['session'];
$session_type = $_POST['session_type'];
$progress = $_POST['progress'];
$previous_session = $_POST['previous_session'];
$verbal = $_POST['verbal'];
$body_language = $_POST['body_language'];
$mood = $_POST['mood'];
$objective = $_POST['objective'];
$assessment = $_POST['assessment'];
$goals = $_POST['goals'];
$quotes = $_POST['quotes'];
$summary = $_POST['summary'];
$formcontent="Client name: $client \n
Date: $date \n
Meeting: $session \n
Session type: $session_type \n
Progress: $progress \n
Previous session: $previous_session \n
Verbal: $verbal \n
Body language: $body_language \n
Mood: $mood \n
Objective: $objective \n
Assessment: $assessment \n
Goals: $goals \n
Client quotes: $quotes \n
Summary of session: $summary";
$recipient = "maryknauth@mac.com";
$subject = "Case notes for $client on $date";
$mailheader = "From: mySportPsych Admin \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You, the case notes submitted have been emailed to $recipient and are also listed below:\n
Client name: $client\n
Date: $date\n
Meeting: $meeting\n
Session type: $session_type\n
Progress: $progress\n
Previous session: $previous_session\n
Verbal: $verbal\n
Body language: $body_language\n
Mood: $mood\n
Objective: $objective\n
Assessment: $assessment\n
Goals: $goals\n
Client quotes: $quotes\n
Summary of session: $summary";?>
Вот форма HTML:
<form action="case_notes.php" method="post">
<h4 class="text-form-section">Overview</h4>
<hr class="style-hr">
<!-- Date -->
<label for="date" class="label">Date</label>
<br>
<input name="date" type="date" class="input-text" id="date">
<br>
<!-- Client -->
<label for="client" class="label">Client</label>
<br>
<input name="client" type="text" class="input-text" id="client">
<br>
<!-- Session -->
<!-- Is this supposed to be a number? -->
<label for="session" class="label">Session</label>
<br>
<input name="session" type="text" class="input-text" id="session">
<br>
<!-- Type of Session -->
<label for="session_type" class="label">Session Type</label>
<br>
<select name="session_type" id="session_type">
<option value="null"></option>
<option value="free">Free Consultation</option>
<option value="initial">Initial Consultation</option>
<option value="regular">Regular Consultation</option>
<option value="termination">Termination</option>
<option value="other">Other</option>
</select>
<br>
<!-- Progress -->
<label for="progress" class="label">Progress</label>
<br>
<select name="progress" id="progress">
<option value="null"></option>
<option value="very_good">Very Good</option>
<option value="good">Good</option>
<option value="none">No Progress</option>
<option value="regression">Regression</option>
</select>
<br>
<br>
<!-- Previous session review -->
<label for="previous_session" class="label">Previous session review</label>
<br>
<input name="previous_session" type="textarea" class="input-text" id="previous_session" rows="5" cols="30">
<br>
<!-- Subject Review -->
<div class="subject review">
<h4 class="text-form-section">Subject</h4>
<hr class="style-hr">
<label for="verbal" class="label">Verbal</label>
<br>
<input name="verbal" type="textarea" class="input-text" id="verbal" rows="5" cols="30">
<br>
<label for="body_language" class="label">Body Language</label>
<br>
<input name="body_language" type="textarea" class="input-text" id="body_language" rows="5" cols="30">
<br>
<label for="mood" class="label">Mood</label>
<br>
<input name="mood" type="textarea" class="input-text" id="mood" rows="5" cols="30">
</div>
<h4 class="text-form-section">Session Review</h4>
<hr class="style-hr">
<label for="objective" class="label">Objective</label>
<br>
<input name="objective" type="textarea" class="input-text" id="objective" rows="5" cols="30">
<br>
<label for="assessment" class="label">Assessment</label>
<br>
<input name="assessment" type="textarea" class="input-text" id="assessment" rows="5" cols="30">
<br>
<label for="goals" class="label">Goals</label>
<br>
<input name="goals" type="textarea" class="input-text" id="goals" rows="5" cols="30">
<br>
<label for="quotes" class="label">Client Quotes</label>
<br>
<input name="quotes" type="textarea" class="input-text" id="quotes" rows="5" cols="30">
<br>
<label for="summary" class="label">Summary</label>
<br>
<input name="summary" type="textarea" class="input-text" id="summary" rows="5" cols="30">
<br>
<br>
<input type="submit" class="button">
</form>