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,8 +27,10 @@ ...@@ -27,8 +27,10 @@
<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"]))
{ {
if (!empty($_GET["From"]) && !empty($_GET["Amount"]) && !empty($_GET["To"])){
$value = $_GET['Amount']; $value = $_GET['Amount'];
$arrFrom = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['From'])->get())->pluck('rates'); $arrFrom = (DB::table('currency')->select('rates')->where('iso', '=', $_GET['From'])->get())->pluck('rates');
...@@ -40,6 +42,7 @@ ...@@ -40,6 +42,7 @@
$rez = ($value/$From) * $To; $rez = ($value/$From) * $To;
echo $rez; echo $rez;
} }
}
?> ?>
</div> </div>
</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