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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀