Note that text shown in this style documents a feature which isn't in the current release but will be in the next release and
text shown thus indicates a feature which is
being removed in the next release.
If you find anything in this documentation which is wrong or unclear then please use the link at the bottom on the page to comment and we will update the page to correct it or make it clearer.
It's sometimes useful to be able to create a form on your web site for the reader to fill in. Opus makes it easy to do this. You need to create two articles. First create an ordinary article which thanks the user for filling in the form and note its URL.
Then create a second article which will contain the form itself. Create an HTML form in the usual way in the article text. The action attribute for the <form> must be the path to ./php/bin/mailform.php and the method attribute must be post.
You can lay it out however you like and include any sort of input fields you like including <textarea>, <select> and <button> fields as well as <input> fields. You can use any name you like for these fields so long as you avoid any with a "x_" prefix.
You should include a number of <input> fields with an type attribute of hidden. The only fields which are compulsory are "x_to" and "x_url".
| name= | value= |
|---|---|
| x_to | Author code of the author to whom the data entered should be sent. |
| x_cc x_bcc |
The author code of the author to whom the data entered should be CCed or BCCed. |
| x_from | The email address from which the data entered should appear to be from (if this isn't set it will probably appear to come from the user under which the web server is running, typically something like www-run or nobody). |
| x_subject | The subject of the email. If not set in the form then this will be set to "Form Data" by Opus |
| x_head x_tail |
The text displayed before and after, respectively, the data entered by the reader. |
| x_url | The URL of the page the reader is taken to after the form has been sent. |
Having to use author codes rather than real email addresses is annoying but it avoids spammers hijacking your page for their own nefarious purposes. If you want the form to be emailed to someone you don't want to be an author just set them up as an author but with a password which you don't ever tell them!
When the form is processed into an email using the fields above each ordinary field on the form is included between the text generated by "x_head" and "x_tail". The fields are labelled with their names from the form, with any underscores replaced with spaces. So if, for example, the field has a name of "text_field" it will be labelled as "text field" in the email.
As always an example is useful so here's one based on a real Opus web site. You can see the form here and try it out for yourself.
<p>Fill in this form then click on "Send". <form action="/php/bin/mailform.php" method=post> <input type=hidden name=x_to value="2"> <input type=hidden name=x_from value="webmaster@opus.cx"> <input type=hidden name=x_subject value="Example Form"> <input type=hidden name=x_head value="This form has been entered via the web site: ---------------------------------------------------------------------------"> <input type=hidden name=x_tail value="---------------------------------------------------------------------------"> <input type=hidden name=x_url value="/opus69.html"> <table> <tr> <td> Text field </td> <td> <input type=text name=text_field> </td> </tr> <tr> <td> Select pulldown </td> <td> <select name=village> <option>Histon <option>Impington <option selected>Milton </select> </td> </tr> <tr> <td> Radio button </td> <td> <input type=radio name=radio_station value=R1> Radio 1 <input type=radio name=radio_station value=R2> Radio 2 <input type=radio name=radio_station value=R3> Radio 3 <input type=radio name=radio_station value=R4 checked> Radio 4 </td> </tr> <tr> <td> </td> <td> <input type=submit value="Send"> </td> </tr> </table>