0

我有一个关于 php 回发的问题

我的代码是:

<?php
if(isset($_POST["Delete"]))
{  
   echo "DELETE";
}

if(isset($_POST["Modifier"]))
{  
   echo "Modifier";
}

if(!empty($_SESSION["Status"]))
{
    if($_SESSION["Status"] == "u")
    {
        header("Location: Index.php?Action=Acceuil");
    }

    if($_SESSION["Status"] == "a")
    {
        $Connection = mysql_connect("localhost","root") or die(mysql_error());                
        mysql_select_db("tpw34") or die("Nope.");                
        $query = "Select * From Products";
        $result = mysql_query($query);


        While($ligne = mysql_fetch_assoc($result))
        {
            //Index.php?Action=AdminDeleteProduct&Delete=".$ligne["ProductID"]."
            echo "<form method='POST' Action='#'>";
                echo "<table border='1'>";
                echo "<tr>";
                echo "<td colspan='2'><center><img  width='250' height='250' src='".$ligne["Image"]."'/></center></td>";
                echo "</tr>";
                echo "<tr>";
                    echo "<th>Nom du produit :</th>";
                    echo "<td>".$ligne["ProductName"]."</td>";
                echo "</tr>";
                echo "<tr>";
                    echo "<th>Prix :</th>";
                    echo "<td>".$ligne["Prix"]."</td>";
                echo "</tr>";
                echo "<tr>";
                    echo "<th>Description :</th>";
                    echo "<td>".$ligne["Description"]."</td>";
                echo "</tr>";
                echo "<tr>";
                    echo "<td colspan='2'h><input type='Submit' value='Delete' name='Delete'/><input type='Submit' value='Modifier' name='Modifier'/></td>";
                echo "</tr>";
                echo "</table>";
                echo "<br>";
            echo "</form>";
        }
    }
}

?>

我的问题是:我想获取项目的 ProductID(在表格中)$_POST["Delete"]$_POST["Modifier"]但我不想更改按钮上的文本。我想保留 DELETE 和 MODIFIER。我在网上阅读了很多东西,但我没有找到正确的答案。

4

2 回答 2

0

您可以使用会话,您可以在其中临时保存您的信息。

会话

或者像 Tim Dearborn 建议的那样,使用隐藏的输入将其与下一个表单提交一起发送。

于 2012-11-04T22:44:55.667 回答
0

包括 ProductID 的隐藏表单值。然后您可以检索 $_POST['ProductID'] 中的值

 echo "<input type=hidden name='ProductID' value='" . $ligne["ProductID"] . "'>";
于 2012-11-04T22:06:04.463 回答