为什么我的PHP代码不打印提交的表单?

时间:2019-02-02 13:13:19

标签: php html

我正在为我的学校项目创建我的第一个Intranet网站,但是一旦我尝试在html中包含简单的php行,则php代码将不起作用

我不知道一小段拒绝工作的代码有什么问题。我需要帮助

<html>
    <head>
        <title> Virtual Faculty </title>
        <meta charset="UTF-8">

            <link rel="stylesheet" href="style1.css">
        </head>
        <body>
            <div>

                    <h1><img class="logo" src="img/casa.jpg" align="middle">VIRTUAL FACULTY</h1>

            </div>

                <nav>
                    <div class="box1" align="middle">
                        <ul>
                            <li><a href="index.html">Home</a></li>
                            <li><a href="ABM11.html">ABM 11</a></li>
                            <li><a href="ABM12.html">ABM 12</a></li>
                            <li><a href="GAS.html">GAS</a></li>
                            <li><a href="HUMMS.html">HUMMS</a></li>
                            <li><a href="STEM11.html">STEM 11</a></li>
                            <li><a href="STEM12.html">STEM 12</a></li>
                        </ul>
                    </div>
                </nav>

                <div class="box2">
                    <h2>You are in:</h2>
                    <h3>ABM 12 Classroom</h3>
                        <img class="img-eye" src="img/das.jpg" alt="Me, the one and only">

<form action="ABM12.html" method="get">
    Name: <input type="text" name="Student">
    <input type="submit">
</form>
<br>

<?php echo $_GET["Student"] ?>

                </div>
            <a href="#here"> Go down to the link </a>
                <a id="here" href="contact.html">Visit my contact page here</a>


        </body>
    </html>    

i just want to print out the Student's name submitted below

1 个答案:

答案 0 :(得分:0)

当您通过表单传递值时,最好使用Post方法

<html>
    <body>
        <form action="//Pass your file name or any url you looking for" method="post">
            Name: <input type="text" name="name"><br>
            E-mail: <input type="text" name="email"><br>
            <input type="submit">
        </form>
    </body>
</html>

,您可以在该文件或最近的文件中使用它

<?php echo $_POST["name"]; ?>