Sunday, 18 August 2013

Adding attributes to HTML tags with PHP

Adding attributes to HTML tags with PHP

What I'm trying to do is change
<input name="username">
to something like
<input name="username" class="empty">
if the form is empty.
Here's the PHP I've got for it in a separate file:
$username = $_POST['username'];
if(empty($username)) {
// add HTML attribute to tag
}
How would I do this?

No comments:

Post a Comment