I am using a Joomla form extension to collect the data from the user. It is supposed to collect the fields named transaction id
and amount
. Now, I've been trying to program the form to check if the record already exists in the database but I keep getting a blank error in my page. Here is my code:
<?php
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$transaction = $app->input->get("transaction");
$query = $db->getQuery(true);
$query->select($db->quoteName('payment_code'))
->from($db->quoteName('#__payment_code'))
->where($db->quoteName('payment_code') . ' = '. $db->quote('$transaction'));
$db->setQuery($query);
$tg = "zuuu";
$result = $db->loadResult();
$min_chars =4;
$max_chars = 15;
$error = "THE transaction ID should not exceed 15 characters.";
$error1="please enter a minimum of 4 characters .";
if (strlen($post["transaction"]) < $max_chars) {
throw new Exception($result);
}
if (strlen($post["transaction"]) < $min_chars) {
throw new Exception($error1);
}
if (strlen($post["amount"]) > $max_chars) {
throw new Exception($error);
}
if (strlen($post["amount"]) < $min_chars) {
throw new Exception($error1);
}
if ($result !== null){
throw new
Exception($tg);
}
?>
echo $query->dump();
die('Copy the above SQL in phpMyAdmin and run it');
$db->quote('$transaction')
to
$db->quote($transaction)