0

Hye there I'm new to PHP and learning to my own I have a simple HTML form as:

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

and my PHP file is:

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

the problem is that when i click on my submit button it only shows the following output:

HELLO Welcome .
You are years old!

I mean the output is not showing up the contents from the POST Function! so is it me doing something wrong or so. I am new to PHP and want to learn it can somebody help me please thanks in advance!

0

1 Answer 1

4

The path for your form action must be a valid web path. Not a file path on your computer:

<form action="/welcome.php" method="POST"> 

or

<form action="http://localhost/welcome.php" method="POST"> 

You also mix HTML in your PHP which should be throwing you a syntax error. When you fix the above that will error out on you.

<body>
HELLO
Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!
</body>
Sign up to request clarification or add additional context in comments.

4 Comments

+1 Yepper. I posted a comment above but I deleted it. The first and last tags needed to be omitted. You've got this one under control ;-)
You're always one step ahead of me. But I blame the cat on my lap for this episode! :)
Well, yes and no. Remember, I type faster ;-) that doesn't necessarily mean I always get it right! haha --- I had cats, now they've been replaced by "cacti". They're meaner.
Thanks and regards you helped me I am totally new and learning PHP thanks so nice of you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.