Commit b2525742 by Florian Shllaku

currency validated with non-numeric value

parent 7fadc840
...@@ -23,6 +23,12 @@ class CurrencyUpdates extends Seeder ...@@ -23,6 +23,12 @@ class CurrencyUpdates extends Seeder
$i = 0; $i = 0;
DB::table('currency')
->updateOrInsert(
['iso' => "EUR", 'name' => "Euro"],
['rates' => 1]
);
foreach($XMLContent as $line){ foreach($XMLContent as $line){
if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){ if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){ if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
......
...@@ -27,18 +27,21 @@ ...@@ -27,18 +27,21 @@
<button class="btn btn--pill" type="submit">Convert!</button> <button class="btn btn--pill" type="submit">Convert!</button>
</form> </form>
<?php <?php
if( isset($_GET["From"])) if( isset($_GET["From"]) && isset($_GET["Amount"]) && isset($_GET["To"]))
{ {
$value = $_GET['Amount']; if (!empty($_GET["From"]) && !empty($_GET["Amount"]) && !empty($_GET["To"])){
$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'); $value = $_GET['Amount'];
$To = $arrTo[0];
$arrFrom = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['From'])->get())->pluck('rates');
$rez = ($value/$From) * $To; $From = $arrFrom[0];
echo $rez;
$arrTo = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['To'])->get())->pluck('rates');
$To = $arrTo[0];
$rez = ($value/$From) * $To;
echo $rez;
}
} }
?> ?>
</div> </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