我正在嘗試創建一個表單,該表單在提交時會將用戶重定向到特定的 URL,該 URL 包含 URL 末尾的提交內容。因此,例如,像這樣的簡單形式:<form method="post"> <input type="text" name="tracking"> <input type="submit" name="submit" value="submit"></form>當用戶鍵入“abc”作為跟蹤號并單擊“提交”時,他們將被重定向到:https://www.specificurl.com/abc我的問題是,這可能嗎?如果可以,怎么做?這是我目前所擁有的......在表單頁面上:<form action="redirect_form.php" id="#form" method="post" name="#form"><label>Enter your tracking code:</label><input id="tracking" name="tracking" placeholder='Enter your tracking code' type='text'><input id='btn' name="submit" type='submit' value='Submit'><?php include "include/redirect.php"; ?></form>包含在 redirect.php 文件中:<?phpif(isset($_POST['submit'])){// Fetching variables of the form which travels in URL$name = $_POST['tracking'];if($tracking){// To redirect form on a particular pageheader("Location:https://specificurl.com/$tracking");}else{?><span><?php echo "Please enter tracking number.";?></span> <?php}}?>
2 回答

白衣非少年
TA貢獻1155條經驗 獲得超0個贊
在這里,JavaScript 可能就足夠了:
<input type="text" id="tracking" name="tracking">
<input type="button" name="submit" value="submit" onclick="window.location.replace('https://www.specificurl.com/'+tracking.value);">
- 2 回答
- 0 關注
- 134 瀏覽
添加回答
舉報
0/150
提交
取消