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.

You can create a simple form by yourself:

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.
}
?>

© 2025 Domeneshop AS · About us · Cookies · Terms · Privacy policy