Commit b2525742 by Florian Shllaku

currency validated with non-numeric value

parent 7fadc840
......@@ -23,6 +23,12 @@ class CurrencyUpdates extends Seeder
$i = 0;
DB::table('currency')
->updateOrInsert(
['iso' => "EUR", 'name' => "Euro"],
['rates' => 1]
);
foreach($XMLContent as $line){
if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
......
......@@ -27,18 +27,21 @@
<button class="btn btn--pill" type="submit">Convert!</button>
</form>
<?php
if( isset($_GET["From"]))
if( isset($_GET["From"]) && isset($_GET["Amount"]) && isset($_GET["To"]))
{
$value = $_GET['Amount'];
$arrFrom = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['From'])->get())->pluck('rates');
$From = $arrFrom[0];
if (!empty($_GET["From"]) && !empty($_GET["Amount"]) && !empty($_GET["To"])){
$arrTo = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['To'])->get())->pluck('rates');
$To = $arrTo[0];
$rez = ($value/$From) * $To;
echo $rez;
$value = $_GET['Amount'];
$arrFrom = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['From'])->get())->pluck('rates');
$From = $arrFrom[0];
$arrTo = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['To'])->get())->pluck('rates');
$To = $arrTo[0];
$rez = ($value/$From) * $To;
echo $rez;
}
}
?>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment