Hexagora Forum
Hexagora Forum
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Dynamic HTML Editor
 Dynamic HTML Editor
 small question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thefool
Practical

26 Posts

Posted - 04 Dec 2005 :  18:11:46  Show Profile  Visit thefool's Homepage  Reply with Quote
Hi!

How can i make a simple form wich will send an email to me?
It shouldnt open the email program. Its for getting on a mailing list..

Thanks :) im really lost on this subject.

s.dav
Site Admin

Italy
3364 Posts

Posted - 05 Dec 2005 :  08:51:06  Show Profile  Visit s.dav's Homepage  Reply with Quote
You can make the half work from Dynamic HTML Editor acting as follow:
1- create a FORM container and set the ACTION property to a server page that will receive the data (this should be a .asp, .php, .jsp, .cfm... page)
2- place the controls you need in the form using relative mode (for more compatibility); you can insert a text for the subject and a text for the body of the message
3- Place a button and set the type to SUBMIT

When a person presses the button the data will be automatically sent to your page.

The content of the server page must be made using another program (I use notepad).
If you need a simple page that manages a mail let me know and I'll send you a piece of mine.

Watch also the Sample 13 - Client Server and the FORM object in the help file.

Regards, Davide
Go to Top of Page

thefool
Practical

26 Posts

Posted - 05 Dec 2005 :  14:26:25  Show Profile  Visit thefool's Homepage  Reply with Quote
Okay. I would like the example page!
I have looked at the example but im probably not hosting at a server supporting iis.
Go to Top of Page

Martin1
Super User

Netherlands
626 Posts

Posted - 05 Dec 2005 :  14:56:32  Show Profile  Reply with Quote
Just to make life easier for Davide (he is currently working on improving the editor) Let me help you with this form.

First of all your server needs to support php.
Second just send me the url to the page that contains the form (if there are fields that are mandatory (they must be filled in by the visitor) please let me know) and I will send you a form script back.
Thirdly I need your e-mail adres so I can send it back to you:-).

Martin

Go to Top of Page

thefool
Practical

26 Posts

Posted - 05 Dec 2005 :  15:25:18  Show Profile  Visit thefool's Homepage  Reply with Quote
It supports php i checked that :)
Sadly i havent got it up yet. I just bought dhe yesterday and im looking at designing it.

However if you could quickly refer how to do it, simply with a Name, Email and Message i would be really happy :)
Go to Top of Page

Martin1
Super User

Netherlands
626 Posts

Posted - 05 Dec 2005 :  17:10:33  Show Profile  Reply with Quote
Here is the html for the form. Just so you know what to call the textfields and so on. And don't forget to use post as a method for the form and action is form.php which is the name of the php script like in this example.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Welcome to my website!</title>
</head>
<body bgcolor="#ffffff">
<form action="form.php" method="post" name="Form">
<input type="text" name="name" size="24" border="0">
<br>
<input type="text" name="email" size="24" border="0">
<br>
<textarea name="message" rows="4" cols="40">
</textarea>
<br>
<input type="submit" name="button" border="0">
</form>
</body>
</html>


Below here you will find the code for the php formscript. You need to look for the line
$emailTo = '"your name" <your@mail.com>';
and change according. So feel free to fill in your name at "your name" and your e-mail address at <your@mail.com>

That's all you need to change.

<?PHP



error_reporting(7);



function check_email($email, $optional)
{
 if ( (strlen($email) == 0) && ($optional === true) ) {
  return true;
 } elseif ( eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$", $email) ) {
  return true;
 } else {
  return false;
 }
}

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
 $ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
 $ClientIP = $_SERVER['REMOTE_ADDR'];
}


$FTGname = $_POST['name'];
$FTGemail = $_POST['email'];
$FTGmessage = $_POST['message'];
$FTGbutton = $_POST['button'];


if (get_magic_quotes_gpc) {
 $FTGname = stripslashes($FTGname);
 $FTGemail = stripslashes($FTGemail);
 $FTGmessage = stripslashes($FTGmessage);
 $FTGbutton = stripslashes($FTGbutton);
}

$validationFailed = false;

if ( (! check_email($FTGemail, false))) {
 $validationFailed = true;
}


if ($validationFailed == true) {

 header("Location: error.html");
 exit;

}


$emailTo = '"your name" <your@mail.com>';

$emailSubject = "Form from your website";
$emailSubject = preg_replace('/[x00-x1F]/', '', $emailSubject);

$emailFrom = "$FTGemail";
$emailFrom = preg_replace('/[x00-x1F]/', '', $emailFrom);

$emailBody = "Name: $FTGname\n"
 . "E-mail: $FTGemail\n"
 . "Message: $FTGmessage\n"
 . "\n"
 . "\n"
 . "";

$emailHeader = "From: $emailFrom\n"
 . "Reply-To: $emailFrom\n"
 . "MIME-Version: 1.0\n"
 . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
 . "Content-transfer-encoding: quoted-printable\n";

mail($emailTo, $emailSubject, $emailBody, $emailHeader);


header("Location: success.html");
exit;

?>


You will also need to create a page that is called error.html just in case something goes wrong when someone tries to submit the form (they fill in a fake e-mail address or something) and you need to create a success.html page so when someone submits the form and all goes well they end up at the success.html page where you can say something like "thank you for filling in our form" or whatever you think of:-)

If you need any help just ask.

Martin
Go to Top of Page

thefool
Practical

26 Posts

Posted - 05 Dec 2005 :  17:27:26  Show Profile  Visit thefool's Homepage  Reply with Quote
Thanks a lot! Ill look at it later tonight. Thanks again!!!
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 07 Dec 2005 :  08:49:38  Show Profile  Visit s.dav's Homepage  Reply with Quote
many thanks Martin ;-)

Regards, Davide
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Hexagora Forum © s.dav Go To Top Of Page
Snitz Forums 2000