小弟初接触PHP,碰到传递的参数不能用的问题,请各位指教。
很简单的两张页面:
1.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>1</title>
</head>
<body>
<form action="youare.php">
Please enter your name:<br>
i am...
<?php print('<input type="text" name="person" value="'. $person .'" size="15">');?>
<input type="submit" value="go" size="15">
</form>
</body>
</html>
youare.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>youare</title>
</head>
<body>
<?php print('hello'.$person .'nice to meet you!');
print('<br>');
print('<a herf = "1.php?person='.$urlencode($person).'">back to 2?</a>');?>
</body>
</html>
从1.php传出来的url可以看到参数值,但是youare.php中就是不能显示出来,参数值没有了,请问为何?
问题点数:20、回复次数:6Top
1 楼forlish(forlish)回复于 2005-07-02 13:44:08 得分 4
1.php的form的method是什么?
youare.php中也没有用get或post获取1.php传来的值。Top
2 楼lhdwh(无敌先锋)回复于 2005-07-02 14:30:36 得分 4
哥们,你又不说怎么传值,youare.php中又不接收值,难不成你想让它自动传送,自动接收!Top
3 楼xmj123()回复于 2005-07-02 14:39:32 得分 4
要么用$_POST,$_GET接收,
要么打开全局变量,不过不建义这样做,最好还是用$_POST,$_GET
养成好习惯Top
4 楼riverking23(真的很菜)回复于 2005-07-02 15:09:13 得分 4
1.php中的form中加入method=post
在youare.php中使用参数前先接收这样写:
$person=$_POST[person];
然后再使用就OK了。Top
5 楼alibaba2008(阿里吧吧)回复于 2005-07-02 16:03:41 得分 4
在php.ini中找到
register_globals = Off
一行,然后把他改成:
register_globals = On
不过前者的安全性要好一些,可以通过$_post和$_get来获得参数。Top
6 楼victorhero(游神)回复于 2005-07-04 09:51:43 得分 0
多谢各位,因小弟一直用的ASP,这两天看PHP的书,开始就是这个程序,书上这样写的,我也纳闷怎么没有接收,所以一问。再次感谢大家。Top




