php页面跳转
2020-11-22 18:27
标签:style blog class code java ext javascript color int 文件 http php中如何跳转,我们看下面的代码 form3.php formprocess3.php You are ‘. $_POST[‘submit‘] .‘int‘;
echo ($_POST[‘submit‘] == ‘Search‘)? ‘for‘:‘‘;
echo ‘a ‘. $foo .‘ named ‘. $name .‘ 注意这一句 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页面跳转,搜素材,soscw.com php页面跳转 标签:style blog class code java ext javascript color int 文件 http 原文地址:http://www.cnblogs.com/tylerdonet/p/3702588.htmlhtml>
head>head>
title>title>
script type="text/css">script>
form action="formprocess3.php" method="post">
body>
table>tr>
td>Nametd>
td>input type="text" name="name" />td>
tr>
tr>
td>Movie typetd>
td>select name="movie_type" id="movie_type">
option value="">Select a movie type...option>
option value="Action">Actionoption>
option value="Drama">Dramaoption>
option value="Comedy">Comedyoption>
option value="Sci-Fi">Sci-Fioption>
option value="War">Waroption>
option value="Other">Otheroption>select>td>
tr>
tr>
td>Item typetd>
td>
input type="radio" name="type" value="movie" checked="checked" />Moviebr />
input type="radio" name="type" value="actor"/>Acotrbr />
input type="radio" name="type" value="director"/>Directorbr />
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>
php
if($_POST["type"] == ‘movie‘ && $_POST["movie_type"] == ‘‘)
{
header(‘Location:form3.php‘);
}
?>
html>
head>
title>php echo $_POST[‘submit‘].‘ ‘.$_POST[‘type‘].‘ ‘.$_POST[‘name‘];?>title>
head>
body>
php
if(isset($_POST[‘debug‘])){
echo‘
‘;
print_r($_POST);
echo‘
‘;
}
else{
echo ‘post‘;
}
$name = ucfirst($_POST[‘name‘]);
if($_POST[‘type‘] == ‘movie‘){
$foo=$_POST[‘movie_type‘].‘ ‘.$_POST[‘type‘];
}
else{
$foo = $_POST[‘type‘];
}
echo ‘
{
header(‘Location:form3.php‘);
}