<html>
<body>

<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>
//welcome.php code
<html>
<body>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!

</body>
</html>

the final out put I get not matter what I input

Welcome.
You are years old!

why doesn't it work? 🙁

    It should work. Are you sure you have PHP installed and set up correctly? Run this script to see:

    phpinfo();

      Nothing seems to be wrong,
      it's giving me all the info....

      I'm running PHP Version 5.1.2
      on a homeserver - EASYPHP 1.8

      what's happenning? 🙁

        As Installer has said it should work. In fact it does work as I copied the code and pasted onto my machine and it worked fine.

        You're phpinfo() might shed some light on the problem.

        Also make sure that you are running the script through the server. For example don't open it up with a path like -----> C:\Program Files\Apache Group\Apache\htdocs\myform.php

        Instead be sure you are using ----> http://localhost/myform.php

        I've been a victim of this easy mistake.

          Welcome <?php echo $_POST["name"]; ?>.<br />
          You are <?php echo $_POST["age"]; ?> years old!
          

          Should be

          Welcome <?php echo $_POST['name']; ?>.<br />
          You are <?php echo $_POST['age']; ?> years old!
          
            SoulAssassin wrote:
            Welcome <?php echo $_POST["name"]; ?>.<br />
            You are <?php echo $_POST["age"]; ?> years old!
            

            Should be

            Welcome <?php echo $_POST['name']; ?>.<br />
            You are <?php echo $_POST['age']; ?> years old!
            

            Why?
            Both examples will work, the type of quote around the POST var name is immaterial in this case.

              Thanks guys, but it was just my home-server that got screwd... 🙁
              it's all OK now, fixed it.

              thx, you're great anyhow !!!

                Write a Reply...