Creating a form (PHP form handler)

This guide will help you to make a form to your website. With this form site visitors can send feedback to your email account. Our site builder has built in modules for making forms, so if you are using our site builder you won’t need this guide.

1. Create a file formHandler.php and add the following code:


<?php
$sender = $_REQUEST['sender'] ;
$message = $_REQUEST['message'] ;
mail( "example@yourdomain.fi", "Form",
$message, "From: $sender" );
header( "Location: http://www.yourdomain.fi/thankYou.php" );
?>

– Change example@yourdomain.fi to your own email address.

– After the visitor presses “Send” button, he/she will be redirected to http://www.yourdomain.fi/thankYou.php. Change this to your liking. You can also upload a thankYou.php file to your website.

– You can create file in file manager found in control panel. Your domains root folder is public_html.

2. Add the following lines to the site you want to show the form:

<form method="post" action="formHandler.php">
Email: <input name="sender" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>

22.05.2014

|