コード例 #1
0
ファイル: index.php プロジェクト: marcossffilho/freteCorreios
<meta name=viewport content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
</head>
<body>

<?php 
$html = "";
if (isset($_GET['frete'])) {
    $servico = $_POST['tipo'];
    $cepOrigem = $_POST['cep-origem'];
    $cepDestino = $_POST['cep-destino'];
    $produtos = $_POST['produto'];
    require_once '../src/Frete.php';
    try {
        $frete = new Frete($servico, $cepOrigem, $cepDestino, $produtos);
        $freteTotal = $frete->calcular();
        $html = "<p class='container text-center alert alert-info'> Frete total = " . "<strong> R\$ " . number_format($freteTotal, 2, ',', '') . "</strong> " . "</p>";
    } catch (Exception $e) {
        $html = "<p class='container text-center alert alert-danger'>" . "<strong>" . $e->getMessage() . "</strong>" . "</p>";
    }
}
?>

<div class="container">
    <h1>Cálculo de frete</h1>

    <div class="row">
        <?php 
echo $html;
?>
    </div>