Can't retrieve numeric input value

I am having trouble retrieving the numeric input and assign it to the variable q. I managed to do so with the variale l and p.

<?php
    $sql = "SELECT * FROM produit";
    $result = mysqli_query($conn, $sql);
        while($row = mysqli_fetch_assoc($result)){
       
    ?>
    <div class="prod<?php echo $row['ID_produit']?>">
        <img src="images/<?php echo $row['image']?>" alt="image">
        <h3><?php echo $row['nom_produit']?></h3>
        <h3>Prix:<?php echo $row['prix']?>&euro;</h6>
        <form action="" method="post">
    	<label name="qte">QTE:</label>
        <input type="number"><br><br>

    	<a href="panier.php?action=ajout&amp;l=<?php echo $row['nom_produit']?>&amp; q= <?php echo $_POST['qte'];&amp;p=<?php echo $row['prix']?>" onclick="window.open(this.href, '', 
    	'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=350'); return false;">
    	GOGOGO	</a>
        </form>
    </div>
    	<?php
    }
    ?>
    </div>

That’s a long line of code, it’s easy to miss stuff. In your case, you’ve missed the closing ?> tag after <?php echo $_POST['qte'];

It’s also risky trying to build a URL in this way; I’m not 100% sure but there are probably some encoding oddities you’re exposing yourself to by trying to do the job yourself. PHP has a function http_build_query that can make it easier for you.

$params = [
    'action' => 'ajout',
    'l' => $row['nom_produit'],
    'p' => $row['prix'],
    'q' => $_POST['qte']
];

$url = 'panier.php?' . http_build_query($url_params);

Then in your html you can use:

<a
    href="<?php echo $url ?>"
    onclick="window.open(this.href, '', 'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=350'); return false;"
>
Sponsor our Newsletter | Privacy Policy | Terms of Service