larry ullman编写php for the web的第四版
第三章在表单处理这块
XXX.html中的内容是这样的:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Feedback Form</title>
</head>
<body>
<!-- Script 3.2 - feedback.html -->
<div><p>Please complete this form to submit your feedback:</p><form action="handle_form.php" method="post"> <p>Name: <select name="title">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Ms.">Ms.</option>
</select> <input type="text" name="name" size="20" /></p> <p>Email Address: <input type="text" name="email" size="20" /></p> <p>Response: This is...
<input type="radio" name="response" value="excellent" /> excellent
<input type="radio" name="response" value="okay" /> okay
<input type="radio" name="response" value="boring" /> boring</p> <p>Comments: <textarea name="comments" rows="3" cols="30"></textarea></p> <input type="submit" name="submit" value="Send My Feedback" /></form>
</div>
</body>
</html>
handle_form.php中是这样的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Your Feedback</title>
</head>
<body>
<?php // Script 3.3 handle_form.php // This page receives the data from feedback.html.
// It will receive: title, name, email, response, comments, and submit in $_POST.// Create shorthand versions of the variables:
$title = $_POST['title'];
$name = $_POST['name'];
$response = $_POST['response'];
$comments = $_POST['comments'];// Print the received data:
print "<p>Thank you, $title $name, for your comments.</p>
<p>You stated that you found this example to be '$response' and added:<br />$comments</p>";?>
</body>
</html>
结果我运行的和书上不一样 我自己写的是这样 用源码也是这样 浏览器是chrome 什么情况呢?环境是xampp搭建的

解决方案 »

  1.   

    xampp你开启了吗  这种说明环境不对  <?php phpinfo();?>测试下  代码没问题
      

  2.   

    开了 刚有测试了phpinfo 显示正确。
    我也奇怪为什么书上那种代码我的浏览器上是这样
    而且后面第五章处理另外的表单时的源码在我这也是这种效果
      

  3.   

    代码你是copy还是键入?键入的话,很像是前一个双引号打成了单引号-->
    print " 打成了 print '
      

  4.   

    我发现如果通过 
    http://localhost:80//handle_form.php 这种方式访问会变成这样也就是说这样子格式是对的 只不过没有前面html提供数据 但是如果用html访问就会出现开始那样的问题
    怎么回事呢?
      

  5.   

    情况明显了,你post失败了第二个文件var_dump($_POST)就知道了
      

  6.   

    上面的错误是些提示,原因是你书上的代码使用的php版本较低,新版本的php加上了这个提示。
    在板块置顶的帖子有提到这个提示
    你可以使用isset(变量) 来避免出现这种提示.