Yep, it's me again.
I've just started learning PHP, and I've already come across something that I can't make work...it should be pretty simple, or at least that's what this tutorial makes out!
---
I am trying to create a simple 2-field form where you input your name and age. You click submit and on the next screen is displayed;
---"Welcome (*name inputed*).
You are (*age inputed*) years old!"
I have been given the following code add to a page;
Then, I'm told, when the user clicks the "Submit" button, the URL sent could look something like this;<form action="welcome.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
The "welcome.php" file can now use the $_GET variable to catch the form data;
---Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
I have tried renaming the page with .HTML and .PHP extensions, and adding <?php ... ?> around the whole page, and just the code...and so on. The best I have managed to achieve so far is have the form working fine, and be redirected to the correct URL like the one shown above, but alas, all that shows is the empty "Welcome", etc. template with the actual name and age missing!
Please, try to sort me out- I suspect it's just me being dim. Oh, and when you reply, talk to me as if I'm a 5-year-old.
MrRSMan.



.
Reply With Quote

Bookmarks