Form not fetched via POST
P粉899950720
P粉899950720 2024-04-02 11:31:12
0
1
425

$product = '';
                            
                            $stmt = $verbinding->query("SELECT 
                            product_category, product_id, parent FROM 
                            Productcategory ORDER BY product_category");

                            $categorien = $stmt->fetchAll();
                           
                                foreach($categorien as $cats){
                                  if($cats['parent'] === $producten){
                                   
                                    echo '<form action="product-list.php" method="post">
                                    <input type="submit" name="cats" value="'. $cats['product_category'] .'"></form>';
                                    echo $producten;
                                    
                                    //var_dump($_POST);
                                    
                                    if(isset($_POST['cats'])){
                                        echo $_POST['cats'];
                                        echo $cats['product_category'];
                                        echo $cats['product_id'];

                                    if($_POST['cats'] === $cats['product_category']){
                                        $product = $cats['product_id'];
                                        echo $product;
                                        echo "gelukt!!";
                                    }
                                    }
                                }
                            }

So, to update my question, this code works partially, but not with the if($_POST['cats'] === $cats['product_id']){ statement. The problem is that my $_POST['cats'] just sends no information. I do not understand why. I should say that although I'm using the same "name" value in another form, if I don't do that it won't even pass the if(isset($_POST['cats'])){ statement.

P粉899950720
P粉899950720

reply all(1)
P粉966335669

From your form, the action page is "product-list.php", is it the same page where you handle the form logic?

If not, then you need to write the following code in the product-list.php you created.

....
      if(isset($_POST['categorien'])){
            echo "pastcategory?";
            if($_POST['categorien'] === $cat['product_category']){
                $producten = $cat['product_id'];
                echo "pastcategory!!!!";
                echo $producten;
            }
        }
     ....
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!