I am working on a simple web form for work that allows a visitor to post a comment about a product. The form only has a text field and submit button which I added to the template. The problem I am trying to solve is to find a way to say which product the person is commenting on without manually adding it to a hidden field for all our products.
Is it possible to pull the title of the page or the file name and populate a field in the form itself so it can be passed to the email script?
Here is the code for the form itself:
[INDENT]<form action=”product_mail.php” method=”post” enctype=”application/x-www-form-urlencoded” name=”prodcommentform1″ id=”formTBL” onsubmit=”this.submit()”>
<p> </p>
<p>Want to tell us what you think? <br>
Feel free to post your comments here:<br>
<textarea name=”Comments” cols=”35″ rows=”3″ id=”Comments”></textarea>
<input name=”Product” type=”hidden” value=”productone”>
</p>
<p><input type=submit class=”formInput” value=Send>
</p>
</form>[/INDENT]
Which sends an email like this:
[INDENT]Product: productone
Comments: test[/INDENT]
but as you can see, I am manually adding the Product hidden field. Since each file name and title are the same as the product name, I am trying to find a way to have it populate that automatically so I can just add the script to the template.
The basic product pages themselves are .php but it looks like the original web guy just took the old html pages and renamed them to .php.