Formular wurde nicht per POST abgerufen
P粉899950720
P粉899950720 2024-04-02 11:31:12
0
1
324

$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!!";
                                    }
                                    }
                                }
                            }

Also, um meine Frage zu aktualisieren: Dieser Code funktioniert teilweise, aber nicht mit der if($_POST['cats'] === $cats['product_id']){-Anweisung. Das Problem ist, dass mein $_POST['cats'] einfach keine Informationen sendet. Ich verstehe nicht warum. Ich sollte sagen, dass, obwohl ich denselben „Name“-Wert in einer anderen Form verwende, die if(isset($_POST['cats'])){-Anweisung nicht einmal übergeben wird, wenn ich das nicht tue.

P粉899950720
P粉899950720

Antworte allen(1)
P粉966335669

从您的表单中,操作页面是“product-list.php”,它是您处理表单逻辑的同一页面吗?

如果没有,那么您需要在您创建的product-list.php 中编写以下代码。

....
      if(isset($_POST['categorien'])){
            echo "pastcategory?";
            if($_POST['categorien'] === $cat['product_category']){
                $producten = $cat['product_id'];
                echo "pastcategory!!!!";
                echo $producten;
            }
        }
     ....
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!