Help with IF rule

A

Anonymous

Guest
I have a page where the user buys credits on my website. I decided to make a rule where the user can buy the credits and be directed to the cart. If he initiates the purchase the value appears, otherwise he emits an empty cart message.

My code:

Code:
<?php
                if (isset($row['userid']) && $row['status'] == 0) {
                    //if ($userid == $userid && $status == 0) {
                    echo "<div class='table-responsive data-table table-striped'>";
                    echo "<table id='activetrontbl' class='table vertical-align' style='width:100%'>";
                    echo "<thead>";
                    echo "<tr class='text-center'>";
                    echo "<th>";
                    echo "<Label>Tokens</Label><br>";
                    echo "</th>";
                    echo "<th>";
                    echo "<label>Quantity</label>";
                    echo "</th>";
                    echo "<th>";
                    echo "<label>Total price</label>";
                    echo "</th>";
                    echo "</tr>";
                    echo "</thead>";
                    echo "<tbody>";
                    echo "<tr class='text-center'>";
                    echo "<td class='align-middle'>";
                    echo "<img src='../assets/images/logo/orico.png' width='42' alt='Jambo'>";
                    echo "<br><small>Jambo - JAM</small>";
                    echo "</td>";
                    echo "<td class='align-middle'>";
                    echo "<h4>$row[chainamount] JAM</h4>";
                    echo "</td>";
                    echo "<td class='align-middle'>";
                    echo "<h4>U$ $row[chaininusdamount]</h4>";
                    echo "<small>R$ ($row[chaininbrlamount])</small>";
                    echo "</td>";
                    echo "</tr>";
                    echo "</tbody>";
                    echo "</table>";
                    echo "</div>";
                    echo "<form action='submit.php' method='post'>";
                    echo "<input type='hidden' name='amount' value='<?php echo $row[chaininbrlamount] * 100; ?>'>";
                    echo "<input type='hidden' name='chainamount' value='<?php echo $row[chainamount]; ?>'>";
                    echo "<input type='hidden' name='userid' value='<?php echo $userid; ?>'>";
                    echo "<input type='hidden' name='updateid' value='<?php echo $row[id]; ?>'>";
                    echo "<input type='hidden' name='name' value='<?php echo $fullname; ?>'>";
                    echo "<input type='hidden' name='email' value='<?php echo $email; ?>'>";
                    echo "<div class='d-flex justify-content-end'>";

                    echo "<script";
                    echo "src='https://checkout.stripe.com/checkout.js' class='stripe-button'";
                    echo "data-key='" . $publishablekey. "";
                    echo "data-amount={$row['chaininbrlamount']*100;}";
                    echo "data-name='chain'";
                    echo "data-quantity='<?php echo $row['chainamount']; ?>'";
                    echo "data-description='buy cryptocurrency'";
                    echo "data-image='../assets/images/logo/orico.png'";
                    echo "data-currency='brl'";
                    echo "data-email=<?php echo $email; ?>";
                    echo ">";
                    echo "</script>";

                    echo "</div>";
                    echo "</form>";
                    echo "</div>";
                } else {
                    echo "<div class='row'>";
                    echo "<div class='col text-center'>";
                    echo "<p><i class='zwicon-sad text-orange h1'></i></p>";
                    echo "<p><spam class='h5'>Your cart is empty!</spam></p>";
                    echo "<p><spam>Add something to make me happy ;)</spam></p>";
                    echo "</div>";
                    echo "</div>";
                } ?>



The problem is in this excerpt. It should display the stripe button for the user to make the purchase:

Code:
echo "<script";
echo "src='https://checkout.stripe.com/checkout.js' class='stripe-button'";
echo "data-key='" . $publishablekey. "";
echo "data-amount={$row['chaininbrlamount']*100;}";
echo "data-name='chain'";
echo "data-quantity='<?php echo $row['chainamount']; ?>'";
echo "data-description='buy cryptocurrency'";
echo "data-image='../assets/images/logo/orico.png'";
echo "data-currency='brl'";
echo "data-email=<?php echo $email; ?>";
echo ">";
echo "</script>";


How can I solve this stretch?
 
Personally, I think you would have an easier time deciphering you PHP from your HTML if you kept them separated as much of possible.

Here's a small example of what I'm talking about :

Code:
<main id="content" class="main">
    <div class="container">
        <?php foreach ($cms as $record) { ?>
            <article class="cms" itemscope itemtype="http://schema.org/Article">
                <header itemprop="articleBody">
                    <div class="byline" itemprop="author publisher" itemscope itemtype="http://schema.org/Organization">
                        <img itemprop="image logo" class="logo" src="assets/images/img-logo-004.png"
                             alt="website logo">
                        <h2 itemprop="headline" class="title"><?= $record['heading'] ?></h2>
                        <span itemprop="name" class="author_style">Created by <?= $record['author'] ?> on
                        <time itemprop="dateCreated datePublished"
                              datetime="<?= htmlspecialchars(CMS::styleTime($record['date_added'])) ?>"><?= htmlspecialchars(CMS::styleDate($record['date_added'])) ?></time></span>
                    </div>
                    <img itemprop="image" class="article_image"
                         src="<?php echo htmlspecialchars($record['image_path']); ?>" <?= getimagesize($record['image_path'])[3] ?>
                         alt="article image">
                </header>
                <p><?= nl2br($record['content']) ?></p>
            </article>
        <?php } ?>
        <?php
            $url = 'index.php';
            echo $pagination->new_page_links($url);
        ?>
    </div>
</main>

I will try to look over your code later on tonight if possible to help you out better or maybe someone else will beat me to the punch?
 
Back
Top