Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html表单php问题_Php - Fatal编程技术网

html表单php问题

html表单php问题,php,Php,这是我的html表单,下面是我的php文本 但是我没有得到正确的输出,我不知道问题出在哪里 我还包括输出,请建议我该怎么做 <html> <head> <title> Entering data into text </title> </head> <body> <h1> Entering data into text </h1> <form action="text.php" method=

这是我的html表单,下面是我的php文本

但是我没有得到正确的输出,我不知道问题出在哪里

我还包括输出,请建议我该怎么做

<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form  action="text.php" method="post">
What is ur name ?

<input  type="text" name="data" />


<input type="submit" value="send" />
</form>
</body>
</html>
问题是,在服务器响应之后,数据发送不包括在内
请尽快帮助我

我只能根据自己的经验发言,但这在我的服务器上有效。那么,我认为以下其中一项是正确的:

  • 您的服务器没有设置为处理php(尽管这会让我感到惊讶),同样,正如@gAMBOOKa(在评论中)所指出的,如果您的服务器没有设置为处理php,脚本将不会输出php脚本的原始文本内容以外的任何内容,字面上是
    “”
  • 您正试图通过文件系统访问页面(
    file:///path/to/file.html
    ),而不是通过服务器(
    http://localhost/file.html
  • 如果“2”正确,请将网页和php脚本移动到服务器文档根目录中,在*nix上,这可能类似于
    /var/www/directoryName/
    ,并通过
    http://localhost/directoryName/dataEntryForm.html
    。如果您在Windows上,使用IIS,可以使用
    C:\inetPub\directoryName\
    访问它,如上所述,使用
    http://localhost/directoryName/dataEntryForm.html


    顺便说一句,请原谅我没有链接到页面运行的演示,只是我不想冒让我的服务器暴露在可能有漏洞的脚本中的风险。

    您的完整代码是这样的,我测试了它,工作得很好

    <html>
    <head>
    <title>
    Entering data into text
    </title>
    </head>
    <body>
    <h1>
    Entering data into text
    </h1>
    <form  action="text.php" method="post">
    What is ur name ?
    
    <input  type="text" name="data" />
    
    
    <input type="submit" value="send" name="btn_save" />
    </form>
    </body>
    </html>
    
    
    将数据输入文本
    将数据输入文本
    你叫什么名字?
    
    text.php

    <?php
    if(isset($_POST['btn_save']))
    {
    
    
             $data=$_POST['data'];
    }
    ?>
    
    <html>
    <head>
    <title>
    Reading data from textfields
    </title>
    </head>
    <body>
    <h1>
    reading data from text field
    </h1>
    Thanks for answering,
    <?php echo $_POST["data"];?>
    </body>
    </html>
    
    
    从文本字段读取数据
    从文本字段读取数据
    谢谢你的回答,
    

    工作完美。

    你能在text.php中打印你通过
    print\r($\u REQUEST)
    得到的东西吗?我是soory,请你再解释一下我是php新手,请帮助我这正是@amitchd想要做的。如他所问,如果您创建一个文本文件
    info.php
    ,请将
    print\r($\u REQUEST)
    的结果输出发布到text.php=)中,其中只有
    的内容,您得到了任何输出吗?如果web服务器没有为php配置,它不应该输出
    ?@gAMBOOKa:是的,它确实应该,但我使用了“[不是]“设置为处理php”是一个委婉的说法,其中包括“未正确设置”。此外,我没有想到。。。已编辑,我的感谢!=)@甘布卡:他只有在试图查看页面来源时才会看到它。在呈现的页面中,它将不可见。@JB:为什么它不可见?对于浏览器来说,它只是纯文本。@fariz,你为Stackoverflow的帮助所付出的代价是对社区的回报=)我建议将该评论作为一个答案发布,详细说明你为解决问题所做的一切。投票选出对你有帮助的答案。此外,它只是“大卫”(或者,最好是“大卫”),“先生”是值得赞赏的,但不必要=)
    <html>
    <head>
    <title>
    Entering data into text
    </title>
    </head>
    <body>
    <h1>
    Entering data into text
    </h1>
    <form  action="text.php" method="post">
    What is ur name ?
    
    <input  type="text" name="data" />
    
    
    <input type="submit" value="send" name="btn_save" />
    </form>
    </body>
    </html>
    
    <?php
    if(isset($_POST['btn_save']))
    {
    
    
             $data=$_POST['data'];
    }
    ?>
    
    <html>
    <head>
    <title>
    Reading data from textfields
    </title>
    </head>
    <body>
    <h1>
    reading data from text field
    </h1>
    Thanks for answering,
    <?php echo $_POST["data"];?>
    </body>
    </html>