因此,假設您有一個帶有文本輸入和提交按鈕的 html 小表單,就像這樣:
<html>
<body>
<form action="index.php" method="post">
Text to encode/decode: <input type="text" name="textoencode"><br>
<input type="submit">
</form>
</body>
</html>
我如何添加另一個按鈕并且 index.php 會知??道我按下了什么按鈕?
另外,我想要做的是讓 php 執行我在另一個檔案中的一些 python 代碼,但我已經知道如何做到這一點。
編輯:我希望我的 php 知道按下了什么按鈕,如果按下編碼,運行一些代碼,如果按下解碼,運行一些其他代碼。
uj5u.com熱心網友回復:
讓我知道這是你想要的嗎?
if當單擊按鈕然后if condition執行內部代碼時,您可以簡單地在 php 中添加一個并在表單中添加簡單的傳遞名稱。
PHP代碼:
<?php
if (isset($_POST['phpbutton'])) {
// Your code that you want to execute
}
?>
HTML :
<html>
<body>
<form action="index.php" method="post">
Text to encode/decode: <input type="text" name="textoencode"><br>
<input type="submit">
<button type="submit" name="phpbutton">press me</button>
</form>
</body>
</html>
如果你想要別的東西,請聯系我
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/337394.html
