如何設(shè)置PHP action的值

PHP
小樊
82
2024-09-14 14:55:54

在HTML表單中,可以通過(guò)<input><button>元素的formaction屬性來(lái)設(shè)置PHP action的值

  1. 使用<input>元素:
<form method="post">
 <label for="name">姓名:</label>
 <input type="text" id="name" name="name" required>
 <input type="submit" value="提交" formaction="your_php_script.php">
</form>
  1. 使用<button>元素:
<form method="post">
 <label for="name">姓名:</label>
 <input type="text" id="name" name="name" required>
 <button type="submit" formaction="your_php_script.php">提交</button>
</form>

在這兩個(gè)示例中,當(dāng)用戶(hù)點(diǎn)擊提交按鈕時(shí),表單數(shù)據(jù)將被發(fā)送到your_php_script.php文件進(jìn)行處理。請(qǐng)確保將your_php_script.php替換為實(shí)際的PHP腳本文件名。

0