PHP代码无法正常工作?

时间:2016-04-02 06:41:07

标签: php web

我是php代码的新手。我的学习.php'代码无法正常工作。我猜POST字段有一些问题。 任何帮助将不胜感激,请为PHP建议一个好的调试器,因为我正在使用WebMatrix。 我的 Index.php 文件:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Information Gethering</title>

    </head>
    <body>
     <h1>Welcome TO my Portal login</h1>   
        <form action="learn.php" method="post">
        First name: <br>
            <input type="text" name="firstname"><br> 
       Last name:<br> 

         <input type="text" name="lastname"><br> 

    Age: <br>

            <input type="text" name="age"><br> 
            <input type="submit" value="Submit">
        </form>
    </body>
</html> 

Learn.php文件:

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Welcome Guest!</title>
    </head>
    <body>
        <?php
        echo" <p>You are logged In Gust!</p>";    
        $firstname=$_POST['firstname'];
        $lastname=$_POST['lastname'];
        $age=$_POST['age'];

        echo'<p> your details are as: </p>';
        echo $name. 'CEO' </br>;
        echo $last. 'WTF?' </br>;
        echo $age. 'Cool' </br>;

        ?>

    </body>
</html>

1 个答案:

答案 0 :(得分:0)

您忘记了变量

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Welcome Guest!</title>
    </head>
    <body>
        <?php
        echo "<p>You are logged In Gust!</p>";    
        $firstname  = $_POST['firstname'];
        $lastname   = $_POST['lastname'];
        $age        = $_POST['age'];

        echo '<p> your details are as: </p>';
        echo $firstname. 'CEO <br>';//changed $name + took </br> in comma + replaced </br> with <br>
        echo $lastname. 'WTF? <br>';//changed $last
        echo $age. 'Cool <br>';

        ?>

    </body>
</html>