PDA

View Full Version : Mailing forms


Anglo
09-18-2007, 02:52 PM
Hey guys and gals :)

I created a form with a submit button.
The button action is the 'cheap'-one --> mailto:
(it's for internal use, so no script needed)

But when the submit button is pressed, it opens up outlook with the form info in it. The user will have to press send in Outlook as well.
Is there a way (there must be?) that the submit button sends the mail without opening the mailprogram?

Any suggestions are welcome
Cheerzzz :)

domedia
09-18-2007, 03:37 PM
Yes, but then you have to use a server side script.

Jittor
09-18-2007, 03:46 PM
yes, you cannot use the mailto: thought because that does just what your seeing - opens the default mail program.

There is a tutorial on this, here is the link

http://www.dreamweaverclub.com/dreamweaver-php-form.php

This tut shows you how to send the form through email without having to use an email program. It used PHP but it is not that hard. Once you get it, it will make your life very easy

This questions seems to come up a number of times throughout the years so you could do a quick search (click search at the top) and I am sure a number of things will pop up.

If after you go through the tutorial you still need help just post your questions and we will help you out.

Anglo
09-18-2007, 05:26 PM
Thanks guys.
I did a search before posting, but I probably entered the wrong parameters.
I'll have a look at the tut which will probably help me out, cheers for that.
I also had a look at some freeware scripts, although it satisfies me more to write it myself. I have some knowledge on Javascript and Actionscript. I'll have to get a book on PHP :wink:

davidj
09-18-2007, 07:33 PM
better than a book...

http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

wasovs4
09-18-2007, 08:12 PM
server side scripting maybe needed ask david Jackson hes very good at helping people

Anglo
09-19-2007, 01:22 PM
Thanks for all the help guys.
I took your tutorial, implemented it, but get the following errors:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in D:\Intranet\html\sendresults.php on line 2

Parse error: syntax error, unexpected T_STRING in D:\Intranet\html\sendresults.php on line 2

-----------------------------

below the script as implemented on the server:

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Feedbacks from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd = 'myname@mydomain.com';

// Where to redirect after form is processed.
$url = 'http://hqweb/';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

davidj
09-19-2007, 01:28 PM
why do you have this line


echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

Anglo
09-19-2007, 01:43 PM
why do you have this line


echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


I just copied the script from the tutorial.
This line is part of it?

davidj
09-19-2007, 01:58 PM
try this script


<?php
if(isset($_POST['submit'])) {

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Me<myemail@hotmail.com>' . "\r\n";
$headers .= "From:".Trim(stripslashes($_POST['email_field'])). "\r\n";
$headers .= 'Cc: whever@example.com' . "\r\n";
$headers .= 'Bcc: whoever@example.com' . "\r\n";


$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field .= $_POST['email'];
$message = $_POST['message'];

/// not sure about this. I would have use sprintf
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";

mail($to, $subject, $body, $headers);

}
?>

Anglo
09-19-2007, 02:08 PM
Thanks David

As said I am not a PHP expert.
Before implement, which line(s) do I alter?
Is the below the only one?

$headers .= 'To: Me<myemail@hotmail.com>' . "\r\n";

And then copy/paste the script over the tutorial one?

Cheers

davidj
09-19-2007, 02:13 PM
you need to start learning PHP then it wont appear like Klingon

if you want to learn then i will help you but you have to really want this

Anglo
09-19-2007, 06:41 PM
you need to start learning PHP then it wont appear like Klingon

if you want to learn then i will help you but you have to really want this

Yes, I do want to learn, so I just started your tutorials on PHP.
I'll go through them first before asking further about scripting.