douzongmu2543 2011-04-08 18:33
浏览 35
已采纳

初学者帮助:无法使表单变量在PHP / HTML中工作

I jut recently started learning PHP from a book called PHP/MySQL Programming for the Absolute Beginner by Andy Harris.

In one of his samples, he writes that this code should function (I've cut it short a bit):

<html>
<head>
<title>Font Choices</title>
</head>
<body>
<center>
<h1>Font Choices</h1>
<h3>Demonstrates how to read HTML form elements</h3>

<form method = "post"
      action = "borderMaker.php">


<h3>Text to modify</h3>
<textarea name = "basicText"
      rows = "10"
      cols = "40">
blah blah
</textarea>



<input type = "submit"
       value = "show me">

</form>

</center>
</body>
</html>

Then in Bordermaker.php something like:

<html>
<head>
<title>Your Output</title>
</head>
<body>
<h1>Your Output</h1>
<center>
<?


print $basicText;

?>
</center>

</body>
</html>

But when i try to run it it says I can't find the $basicText variable.

I'm currently learning PHP with XAMPP running on my computer.

Thanks for any help.

  • 写回答

2条回答 默认 最新

  • dongsheng9203 2011-04-08 18:35
    关注

    use $_POST['basicText'] instead of $basicText

    You are using the "post" method on your form so all your input values will be contained in an array called $_POST.

    If you were using "get" as your method, all the form information would be passed as a query string on the end of your url, and you would access them with an array called $_GET the same way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献