我正在尝试创建一个表单,该表单在提交时会将用户重定向到特定的 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 关注
- 139 浏览
添加回答
举报
0/150
提交
取消