Jums jāizstrādā kāda lielāk projekta prototips. Izstrādājot prototipu, paturiet prātā, ka projektam attīstoties, šo prototipu varētu vajadzēt pilnveidot.
<?php
require("header.php");
$errors = array();
?>
<div class="alert alert-primary" role="alert">
Here you can request a loan.
</div>
<?php
$form_valid = true;
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["btnSend"]))
{
$email = $_POST["txtEmail"];
$amount = $_POST["txtCreditAmount"];
if (empty($email))
{
$form_valid = false;
$errors["email"] = "Please enter email.";
}
if (empty($amount))
{
$form_valid = false;
$errors["amount"] = "Please enter amount.";
}
else if ($amount <= 0)
{
$form_valid = false;
$errors["amount"] = "Amount cannot be less than 0.";
}
if ($form_valid)
{
$app_manager = new ApplicationManager();
$app_manager->createApplication($email, $amount);
header("Location: application-sent.php");
die();
}
}
?>
<?php
if (count($errors) > 0)
{
?>
<ul style="color: #f00">
<?php
foreach ($errors as $key => $value)
{
echo "<li>".$value."</li>";
}
?>
</ul>
<?php
}
?>
<div class="row justify-content-center align-items-center h-100">
<div class="col col-sm-4 col-md-4 col-lg-4 col-xl-3">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" class="needs-validation" novalidate>
<div class="form-group">
<label for="txtEmail">Email</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">@</div>
</div>
<input type="email" class="form-control" id="txtEmail" name="txtEmail" />
<div class="invalid-feedback">
Please enter email.
</div>
</div>
</div>
<div class="form-group">
<label for="txtCreditAmount">Amount</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">€</div>
</div>
<input type="number" class="form-control" id="txtCreditAmount" name="txtCreditAmount" />
<div class="invalid-feedback">
Please enter amount.
</div>
</div>
</div>
<button type="submit" name="btnSend" class="btn btn-primary">Send</button>
</form>
</div>
</div>
<?php
require("footer.php");
?>
<script type="text/javascript">
(function() {
'use strict';
window.addEventListener('load', function() {
var forms = document.getElementsByClassName('needs-validation');
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>