在HTML表單中,可以通過(guò)<input>
或<button>
元素的formaction
屬性來(lái)設(shè)置PHP action的值
<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>
<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腳本文件名。