QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1179|回复: 7

求教linux下php问题,请高手指点

[复制链接]
发表于 2004-3-13 16:43:41 | 显示全部楼层 |阅读模式
各位大侠:
小弟初学php ,问一个很弱的问题!!
apache服务器配置好了以后,写了第一个php网页
php例题 1 可以正常显示日期年月 测试成功:
<html>
<head>
<title> no1</title>
</head>
<body>
today's date:
<?
printf(date("l F d ,y"));
?>
</body>
</html>
例题2 页面表单的变量不能提交 不能成功
..
<body>
<form action ="no3.php" method="post">
your name:
<input type="text" name="yourname"><br>
<input type="submit " name="x" value="compute">
</form>
</body>
...
题目2(no3.php)
....
<body>
this is a php test!
<?
print("you are $youname");
?>
</body>
提交以后 页面显示

this is a php test
you are

为何变量$yourname的值无法传递到php3.php页面!???
望高手赐教!!
发表于 2004-3-13 18:04:35 | 显示全部楼层
$_POST["yourname"]
回复

使用道具 举报

 楼主| 发表于 2004-3-13 22:00:25 | 显示全部楼层
谢谢大哥 !卖血了给你发烟抽
....
<body>
this is a php test!
<?
print("you are $_post[youname]");
?>
</body>
是这样改么??
为什么我还是不行啊
提交表单的动作post已经在前面设定好了啊,怎么还是不行啊??
原谅我太无知,请告诉我好么?
name ="$_post[youname]" 这个变量在第一个页面就这么定义么?
这样我也试过了,也不行啊?

附完整代码 :
/******index.php********/
<html>
<head>
<Title> this is a php test</Title>
</head>
<body>

<Form action="1-6.php" METHOD="post">
your name:
<input type ="text" name=$_POST["yourname"]><br>
cost of a lunch:
<input type ="text" name="CostOfLunch"><br>
days buying lunch:
<input type ="text" name="DaysBuyingLunch"><br><br>
<input type ="submit" name="x" value="compute">

</Form>
</body>
</html>


/********1-5.php**********/
<?
$today =date("l F d, y");
?>
<html>
<head>
<title>listing 1-5</title>
</head>
<body>
today's date:
<?
print("<h1>$today</h1>\n");
print("$YourName, You will be out");
printf($CostOfLunch * $DaysBuyingLunch);
print("dollars this week.<br>\n");
?>
</body>
</html>

提交后页面值能显示:

today'sdate:
  sunday ......2004
   you will be out  doloars this week.
由页面index.php的表单提交的变量似乎没有传递到1-5.php
是什么原因呢?????好苦闷啊?
回复

使用道具 举报

发表于 2004-3-14 15:27:09 | 显示全部楼层
PHP 4.2.0 以后(应该是这个版本)为了保证安全性。
默认所有表单、Session、Cookie、Url需要加相应的前缀:
$_POST["xxxx"]
$_GET["xxxx"]
$_SESSION["xxx"]
……………(自己去查吧,我也记不清了)

所以如果一个表单:
[code:1]
<form action ="no3.php" method="post">
your name:
<input type="text" name="yourname"><br>
<input type="submit " name="x" value="compute">
</form>
[/code:1]
想获得它的 yourname 变量PHP里需要用:
$_POST["yourname"]

例如:在网页里显示这个text框里的内容,PHP代码应该这样写:
echo "your name:" . $_POST["yourname"];


所以:你的书太旧了~~
回复

使用道具 举报

 楼主| 发表于 2004-3-14 19:47:17 | 显示全部楼层
谢谢  我已经搞定了 谢谢各位
$_POST["yourname"]
果然有效  !!
回复

使用道具 举报

发表于 2004-3-19 16:45:12 | 显示全部楼层
今天我也碰到了这个问题,想不到随便逛逛论坛就看到这编。斑竹先生,你真是个好人。
回复

使用道具 举报

发表于 2004-3-19 16:49:16 | 显示全部楼层
不过我还有一个问题就是在win2000下为什么php不能访问mysql呢,在php.ini中并没有extention=php_mysql.dll这一项,是不是要下一个mysql.dll呢,如果是的话,能否上传一个及具体配置方法。原谅我是一个新手!拜托。
回复

使用道具 举报

发表于 2004-3-21 17:31:32 | 显示全部楼层
怎么不能访问?
错误提示是什么?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-10 12:38 , Processed in 0.084613 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表