如何使用PHP表单?

如何使用PHP表单?,php,forms,web,parameters,Php,Forms,Web,Parameters,我的Web服务器上有一个支持php的php文件 $Content=$_POST['Content'] echo$内容 当我打开名为put.php的文件时,put.php?Content=200什么都没有发生 也许你们中的任何人都可以帮助我。我已经读到,它使用一个html文件运行,用户在其中填写der信息并按下按钮发送,但我只想用指定的信息打开php文件 提前感谢。在PHP中,$\u POST指由表单提交设置的变量 $\u GET用于获取查询字符串参数,即put.php?Content=200

我的Web服务器上有一个支持php的php文件

$Content=$_POST['Content']

echo$内容

当我打开名为put.php的文件时,put.php?Content=200什么都没有发生

也许你们中的任何人都可以帮助我。我已经读到,它使用一个html文件运行,用户在其中填写der信息并按下按钮发送,但我只想用指定的信息打开php文件


提前感谢。

在PHP中,
$\u POST
指由表单提交设置的变量

$\u GET
用于获取查询字符串参数,即
put.php?Content=200

echo $_GET['Content'];

请注意,直接回显
$\u GET
$\u POST
可以打开您的站点,使其被用于XSS攻击。

下面是一个POST表单示例。正如Machavity告诉你的那样,这样做是不安全的,但它会教会你一些基本知识。我在里面放了一些评论,告诉你到底在做什么

<?php

/*
First we'll make an if statement that checks if there's actually
a username set. In here you'll see "isset". This checks if the POST
variable 'username' exists. Secondly you see "empty". This will
check if the variable is empty. Ofcourse we don't want it to be
empty, so we'll put a ! in front of it. This makes it do exact opposite
and check if it's NOT empty.
*/
if(isset($_POST['username']) && !empty($_POST['username'])){
    //Here we'll echo a message to the user with his username and
    //2 returns so the form is a little bit further down.
    echo "Hello, " . $_POST['username'] . "<br /><br />";
}

//With this we can even give the user a message when he tries to
//sumit the form without entering a username at all.
if(empty($_POST['username'])){
    echo "You did not enter a username! <br /><br />";
}

?>

<!DOCTYPE HTML>
<html>
    <head>
        <title>Please enter your username</title>
    </head>
    <body>
        <!-- With method set to post, we're telling the form that we're using POST and not GET -->
        <!-- You should save this file as "example.php" as we're telling it to send the form data -->
        <!-- towards example.php. -->
        <form method="post" action="example.php" accept-charset="utf-8">
            Please enter your username: <input type="text" name="username" /><br />
            <input type="submit" value="Send" />
        </form>
    </body>
</html>

这是因为Content=200是GET方法的一部分。不邮寄。尝试$Content=$\u获取['Content'];相反;)你是对的。谢谢你。我能做什么,这是帖子,我读过帖子有更大的容量??感谢安全证据。实际上,我只是想了解如何保存PHP表单,稍后我会将值放在数据库中,返回true或false,您还需要一个ID来运行脚本。在大多数情况下,我将在移动应用程序中使用它。但是谢谢你的证据:)!!!