Frequently asked questions

Back
Keyword:  

How do I make a contact or feedback form?
We recommend that the form is protected with a captcha solution, e.g. hCaptcha or reCaptcha, to reduce spamming.

Alternative 1: Our standard form

If you want a contact or feedback form on your website, e.g. to allow visitors to fill out a form that's e-mailed to you, you may use our standard CGI script for feedbacks.

We assume that you know a bit about coding in HTML, and that you control the email sender and recipient used.

Domainnameshop must also be approved sender of email for the domain in the sender address (DMARC must validate when we send).

Create a HTML form (<FORM>) with the following action parameter: action="https://www.domeneshop.no/cgi-bin/mailto.cgi" accept-charset="ISO-8859-1". Add hidden input fields with values for "_to", "_from", "_subject" and"_resulturl". Any input field without the underscore ("_") prefix will be sent as a part of the message itself.

Example:

<form method="POST" action="https://www.domeneshop.no/cgi-bin/mailto.cgi" accept-charset="ISO-8859-1">
<input type="hidden" name="_to" value="yourname@yourdomain.com">
<input type="hidden" name="_from" value="feedback@yourdomain.com">
<input type="hidden" name="_subject" value="Feedback">
<input type="hidden" name="_resulturl"
value="https://www.domainnameshop.com/eksempler/receipt.html">
...
<input type="text" name="Field1" value="Enter your question">
<input type="checkbox" name="Field2" value="Yes">
<input type="radio" name="Field3" value="1">
<input type="radio" name="Field3" value="2">
...
<input type="submit" value="Send">
</form>

After creating your form, you must login to the web control panel and register the e-mail addresses you placed in the "_from" and "_to" fields as a valid sender-recipient address combination. (Select your domainname, select "Web hosting" from the menu, and then "View/change" for "Feedback form".)

Both the sender and recipient addresses must be at your domain, and must be verified in the control panel.

This must be done for any web hosting with such a form, regardless of whether the sender and recipient are approved and verified for another web hosting.


Alternative 2: Creating your own form

If you have Webhotel Medium or larger, you may also create your own feedback forms with PHP or CGI scripts. This is advisable only for experienced users who know a bit of programming.

A PHP example follows below. We have assumed that the input fields from your home-made HTML form are "name" (the sender's name), "email" (the sender's e-mail address) and "message" (the message text). The script does not permit you to click on "reply" in your e-mail program to send a response directly to the claimed sender. It is important that the form does not permit anyone to enter information used for the sender or recipient addresses, and that both these addresses are under your control.

<?php
// Fetch the values from the form
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

// Check for invalid characters in e-mail and name.
// Accept certain European special characters.
// Prevent messages longer than 500 characters.
// This reduces the risk of spamming.

if(preg_match("#[-a-zA-Z0-9éèÉÈäöæøåÄÖÆØÅ._ ]+#",$name) AND
   preg_match("#[-a-zA-Z0-9.@+!=()_:]+#",$email) AND
   strlen($message) < 500) {

  if (mail("yourname@yourdomain.com", // your e-mail address
           "Feedback from your webpage", // subject
           "Message from $name <$email>:\n\n$message", // the message text
           "From: Feedback form <yourname@yourdomain.com>" // the sender
          )) {
?>

<p>The message has been sent.</p>

<?php
  } else {
?>

<p>Failed to send the message via e-mail,
please get in touch via phone or postal mail.</p>

<?php
} else {
?>

<p>Invalid request. The attempt has been logged.</p>
<p>
Names may only contain the characters <code>-a-z0-9éèäöæøå._</code>,
e-mail addresses only <code>-a-zA-Z0-9.@+!=()_:</code>,
and the message may not be longer than 500 characters.</p>

<?php
  # Probably abuse, add logging of the request here.
}
?>

© 2024 Domeneshop AS · About us · Terms · Privacy policy