I just started learning php yesterday, and had a question about the example code below.
<form action='action.php' method='post'>
<input type='text' name='foo' />
</form>
And my action.php:
<?php
$foo = htmlspecialchars($_POST['foo']);
echo $foo;
?>
So, my question is this: Right now, it seems like the only way to access html elements with php is via the “name” attribute. Is this true? Or is there another way in which to do it? I’m mainly asking because I know that attribute is deprecated in xhtml, so I’m looking for a way around that.
Thanks!
nameattribute is deprecated just in<a>kind of elements, feel free to use it in forms: it is the the key to generate theapplication/x-www-form-urlencodedHTTP request.