Here's the main index page:

<html>
<body>

<form action="action.php" method="post">
Name: <input type="text" name="fname">
Age: <input type="text" name="age">
<input type="submit" name="mybutton" />
</form>

</body>
</html>

Here's the action page:

<?php
$mycar='';
echo "$mycar";

?>

I left the variable $mycar empty because i'm trying to assign it's value as my forms name (fname).
How do I do this?
I'm so confused!

$mycar = $_post['fname'];
echo $mycar;

@klemme,

Thanks for your help.
You're awesome. :-)

Member Avatar for Zagga

To expand a little on what klemme mentioned, because your form is set to "post" method, all the form fields can be collected in action.php with $_POST['field_name']
If the method was set to "get" you could collect the fields with $_GET['field_name'] and these variables will also be in the URL (added to the end of action.php).

Please mark this as solved, it still shows as an open thread in forum, thanx.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.