2013-08-20 93 views
-2

我想將它們格式化爲表單中的按鈕。多個php表單按鈕

<p><a href="<?=$_SERVER['PHP_SELF'] . "?action=moveForward" ?>">forward</a></p> 
<p><a href="<?=$_SERVER['PHP_SELF'] . "?action=moveBackward" ?>">backward</a></p> 
<p><a href="<?=$_SERVER['PHP_SELF'] . "?action=moveLeft" ?>">left</a></p> 
<p><a href="<?=$_SERVER['PHP_SELF'] . "?action=moveRight" ?>">right</a></p> 

事情是這樣的......

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> 
<input type="submit" name="moveForward" value="forward"> 
<input type="submit" name="moveBack" value="back"> 
<input type="submit" name="moveLeft" value="left"> 
<input type="submit" name="moveRight" value="right"> 
</form> 
+0

只有通過JavaScript –

+0

PS。你有一個HTML注入漏洞導致潛在的跨站腳本攻擊。輸出到HTML文件中的所有變量,包括'$ _SERVER ['PHP_SELF']',都需要封裝在'htmlspecialchars()'中。 – bobince

回答

0
<input type="submit" name="action" value="moveForward"> 
<input type="submit" name="action" value="moveBack"> 
<input type="submit" name="action" value="moveLeft"> 
<input type="submit" name="action" value="moveRight"> 
+0

這麼簡單...謝謝! – user1919580

+0

頭接桌子。 – Hamish