php頁面跳轉

2022-02-11 06:11:23 字數 3838 閱讀 9581

php中如何跳轉,我們看下面的**

form3.php

<

html

>

<

head

>

head

>

<

title

>

title

>

<

script

type

="text/css"

>

script

>

<

form

action

="formprocess3.php"

method

="post"

>

<

body

>

<

table

><

tr>

<

td>name

td>

<

td><

input

type

="text"

name

="name"

/>

td>

tr>

<

tr>

<

td>movie type

td>

<

td><

select

name

="movie_type"

id="movie_type"

>

<

option

value

="">select a movie type...

option

>

<

option

value

="action"

>action

option

>

<

option

value

="drama"

>drama

option

>

<

option

value

="comedy"

>comedy

option

>

<

option

value

="sci-fi"

>sci-fi

option

>

<

option

value

="war"

>war

option

>

<

option

value

="other"

>other

option

>

select

>

td>

tr>

<

tr>

<

td>item type

td>

<

td>

<

input

type

="radio"

name

="type"

value

="movie"

checked

="checked"

/>movie<

br />

<

input

type

="radio"

name

="type"

value

="actor"

/>acotr<

br />

<

input

type

="radio"

name

="type"

value

="director"

/>director<

br />

td>

tr>

<

tr>

<

td>

td>

<

td><

input

type

="checkbox"

name

="debug"

id="debug"

checked

="checked"

/>

display debug info

td>

tr>

<

tr>

<

td colspan

="2"

style

="text-aligh:center"

>

<

input

type

="submit"

name

="submit"

value

="search"

/>

<

input

type

="submit"

name

="submit"

value

="add"

/>

td>

<

td>

td>

tr>

table

>

body

>

form

>

html

>

formprocess3.php

<?

phpif($_post["type"] == 'movie' && $_post["movie_type"] == '')

?>

<

html

>

<

head

>

<

title

>

<?

php echo $_post['submit'].' '.$_post['type'].' '.$_post['name'];

?>

title

>

head

>

<

body

>

<?

php if(isset($_post['debug']))

else

$name = ucfirst($_post['name']);

if($_post['type'] == 'movie')

else

echo 'you are '. $_post['submit'] .'int';

echo ($_post['submit'] == 'search')? 'for':'';

echo 'a '. $foo .' named '. $name .'

';

?>

body

>

html

>

注意這一句

if($_post["type"] == 'movie' && $_post["movie_type"] == '')

如果選擇movie型別並且傳入的movie_type為空則返回到form3.php頁面中header()方法引數是以分號分割的字串前面是location,後面是要跳轉的頁面位址。

head()函式是輸出乙個原始的http頭,php請求頁面的時候會首先自動輸出http頭,並且值輸出一次,所以這個方法必須在html檔案的開頭使用,前面不能有echo,print之類的輸出語句,也不能有html**和空格之類的,否則有可能呼叫失敗。

還有一點這裡有兩個submit按鈕但是value的值不一樣,我們可以根據這個值來進行不同的邏輯處理。

PHP頁面跳轉

if isset url url echo cho meta http equiv refresh content 秒數 url 跳轉的檔案或位址 其中 xx是秒數,0為立即跳轉.refresh 是重新整理的意思.url 是要跳轉到的頁面.url echo 其中 更改 self 就可以實現跳轉限制原...

PHP頁面跳轉

header 函式的主要功能是將http協議標頭 header 輸出到瀏覽器。語法header string,replace,http response code string 必需。規定要傳送的報頭字串。replace 可選。指示該報頭是否替換之前的報頭,或新增第二個報頭。預設是 true 替換 ...

php頁面跳轉

php中如何跳轉,我們看下面的 form3.php html head head title title script type text css script form action formprocess3.php method post body table tr td name td td ...