在PHP里表单的信息怎么接收?
<?phpinclude("include/common.inc");$title="表单实验";include("include/header.inc");?><p><...
<?php
include("include/common.inc");
$title="表单实验";
include("include/header.inc");
?>
<p>
<form action="deal.php" method="post">
姓名:<input type="text" name="name" value="你的名字" size="20" maxlength="30">
<br>
E-mail:<input type="text" maxlength="40" width="20" value="您的E-mail"
name="email">
<br>
<textarea rows="7" cols="40" name="comment">
请输入您的留言信息
</textarea>
<br>
<input type="submit" value="提交">
</form>
</P>
---------------------------------------------
<?php
include("include/common.inc");
$title="表单处理页";
include("include/header.inc");
if($name == "" || $name == "你的名字")
echo "请输入您的姓名";
else
{
echo "$name,您好,欢迎您的光临!";
}
?>
-------------------------------
不是说直接用$name就可以接收我表单中name的内容了吗?
但是还是报错
Notice: Use of undefined constant name - assumed 'name' in C:\Program Files\EasyPHP 3.0\www\deal.php on line 5
Notice: Undefined variable: _post in C:\Program Files\EasyPHP 3.0\www\deal.php on line 5
请输入您的姓名 展开
include("include/common.inc");
$title="表单实验";
include("include/header.inc");
?>
<p>
<form action="deal.php" method="post">
姓名:<input type="text" name="name" value="你的名字" size="20" maxlength="30">
<br>
E-mail:<input type="text" maxlength="40" width="20" value="您的E-mail"
name="email">
<br>
<textarea rows="7" cols="40" name="comment">
请输入您的留言信息
</textarea>
<br>
<input type="submit" value="提交">
</form>
</P>
---------------------------------------------
<?php
include("include/common.inc");
$title="表单处理页";
include("include/header.inc");
if($name == "" || $name == "你的名字")
echo "请输入您的姓名";
else
{
echo "$name,您好,欢迎您的光临!";
}
?>
-------------------------------
不是说直接用$name就可以接收我表单中name的内容了吗?
但是还是报错
Notice: Use of undefined constant name - assumed 'name' in C:\Program Files\EasyPHP 3.0\www\deal.php on line 5
Notice: Undefined variable: _post in C:\Program Files\EasyPHP 3.0\www\deal.php on line 5
请输入您的姓名 展开
1个回答
展开全部
表单传值有两种方式分别为:
get (通过URL进行传值,这种方式并不安全);
post(封装到一个post包中进行传递,比get安全,一般用这个)
下面我们用$_POST进行传值:
<?php
include("include/common.inc");
$title="表单处理页";
include("include/header.inc");
if($_POST['name'] == null || $_POST['name'] == "你的名字")
echo "请输入您的姓名";
else
{
echo "$name,您好,欢迎您的光临!";
}
?>
get (通过URL进行传值,这种方式并不安全);
post(封装到一个post包中进行传递,比get安全,一般用这个)
下面我们用$_POST进行传值:
<?php
include("include/common.inc");
$title="表单处理页";
include("include/header.inc");
if($_POST['name'] == null || $_POST['name'] == "你的名字")
echo "请输入您的姓名";
else
{
echo "$name,您好,欢迎您的光临!";
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询