0

I am newbie to php code. My 'learn.php' code is not working properly. I guess there is some problem with the POST fields. Any helps would be appreciated and please suggest a good debugger for php as i am using WebMatrix. My Index.php File:

<!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 file:

<!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 Answers1

0

You are forgetting your variables

<!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>
Praveen Kumar
  • 2,388
  • 1
  • 9
  • 20
  • Thanks and what debugger should i use? – M.Usman Siddiqui Apr 02 '16 at 06:55
  • I never needed them. browser does this for me... – Praveen Kumar Apr 02 '16 at 06:57
  • You need to turn on error reporting. That will show you PHP errors in the browser. Add this tag to the top of your file . Learn more about error reporting at: http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display and http://php.net/manual/en/function.error-reporting.php – Liren Apr 02 '16 at 06:59