[英]How to redirect to a particular form in html page using php header?
在我的index.php
中,我有 2 個表單,當單擊相應的鏈接時,它們使用轉換來移動頁面(登錄注冊,反之亦然)。 當我嘗試在后端注冊時,我正在檢查用戶是否存在。 如果用戶確實存在,那么我將重定向到主文件 index.php。 問題是登錄頁面是刷新 index.php 時加載的默認頁面。 我嘗試在后端代碼中運行標頭函數后運行 js,以編程方式單擊登錄頁面中的注冊頁面鏈接。 但這似乎不起作用。
index.php -> 包含 2 個注冊和登錄表單
<html>
<form action="register.php" method="post">
<button type=submit>
</form>
<form action="login.php" method="post">
<button type=submit>
</form>
</html>
注冊.php
if (user_exist){
header("Location: index.php"); //redirects to index.php
}
上面的標題重定向到 index.php 專門的登錄頁面,但我需要注冊頁面。 有沒有辦法使用表頭中的表單 ID 或類來進行轉換?
您可以只調用header
函數並指定Location
,如下所示:
header('Location: your/path/to/the/page');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.