This also looks up and validates a bank sort code and account number. It works as a standalone php form but it's not clear to me how to then use formit and a snippet to achieve the same result.
The form, stripped down is:
<label for="sortcode">Sort Code<span class="error">[[!+fi.error.sortcode]]</span></label>
<input type="text" name="sortcode" value='<?php if(isset($_POST['sortcode'])) { echo htmlentities ($_POST['sortcode']); }?>' /> // set to retain the input in the input field
<label for="AccountNumber">Account Number</label>
<input type="text" name="AccountNumber" value='<?php if(isset($_POST['AccountNumber'])) { echo htmlentities ($_POST['AccountNumber']); }?>' /> // set to retain the input in the input field
<input class="button" name="click" type="submit" value="Check bank account details" />
PHP
if(isset($_POST['click']))
{
$sortcode = $_POST['sortcode'];
$AccountNumber = $_POST['AccountNumber'];
.
> external database call, which returns array
.
$data = $pa->HasData();
foreach ($data as $item)
{
$varVerifyAccount = $item["AccountVerification"];
more items from array...
So the external call checks the account and we use $varVerifyAccount to advise the user whether or not the account may be used. You can see how the form looks here:
http://pfsmedia.net/letusfixit/account-form.php
Can someone give me a steer how to code the snippet? Also, you see I'm keen to retain the values in the input fields after submit is clicked. Not sure how to do that in formit.
Thanks