I want to add another input or button next to the submit which will clear the form.
The problem I've found is that because the form uses $_POST to keep its values after the form is submitted (a feature I want to keep), it seems to prevent something like <input type="reset" value="Reset" name="reset" />
from working.
This is the code:
<form method="post" action="<?php echo htmlspecialchars ($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="<?php echo $name;?>">
<span class="error">* <?php echo $nameErr;?></span><br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
<span class="error">* <?php echo $emailErr;?></span><br>
Website: <input type="text" name="website" value="<?php echo $website;?>">
<span class="error"><?php echo $websiteErr;?></span><br>
Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea><br>
Gender:
<input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female
<input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male
<span class="error">* <?php echo $genderErr;?></span><br>
<input type="submit" name="submit" value="Submit">
<input type="reset" value="Reset" name="reset" />
</form>