PDA

View Full Version : Email Form


mimpoz
08-12-2003, 07:31 PM
I set up an form on my website (a simple text box, message box and submit button) that I would like to be posted to my email address. Is there any way to do this in Javascript??

petervazed
08-12-2003, 07:59 PM
No, not javascript but a CGI or PHP script.
But your host has to support CGI or PHP.
Or simple: use the mailto in the form.
<form method="post" action="mailto:yourname@yourhost.com" enctype="text/plain">

PHP script how to:
http://www.clockwatchers.com/php_intro.html
(in the middle of the page)

:rocker:

mimpoz
08-12-2003, 08:28 PM
Thanks for the tip. The form works great, but I see that after it posts, the page stays at php page. How can I get it to refresh back to the htm page that the user was on before??

you can check out:
http://www.theknish.com/sub.htm

Thanks for all your help!

petervazed
08-13-2003, 06:09 AM
See this test:
http://members.lycos.nl/vazed/form_test.html

What page do you want to show?
Well, take this page, save as hallo.php

And in this page you put the code, like this:


<?php
$senderemail = $_POST['email'];
$sendername = $_POST['name'];
$sendercolor = $_POST['color'];
$recipient = "vazed@zeelandnet.nl";
$subject = "Test form PHP";
$mailheader = "From: $senderemail\n";
$mailheader .= "Reply-To: $senderemail\n\n";
$message = "Sender's name: $sendername\n";
$message .= "Sender's favorite color: $sendercolor\n\n";
mail($recipient, $subject, $message, $mailheader) or die ("Failure");
?>
<?
print ("Thanks ".$sendername.", for your reply");
?>


only this line is added:
print ("Thanks ".$sendername.", for your reply");

Now the visitor has a normal webpage.



:rocker:

mimpoz
08-13-2003, 08:52 AM
I would like the user to get back to the sub.htm page so he can submit another article.

petervazed
08-13-2003, 11:12 AM
In that way ;)

in the hallo.php put this in the head:
<META HTTP-EQUIV="Refresh" CONTENT="15; URL=submitpage.html">


:rocker:

mimpoz
08-13-2003, 03:25 PM
I'm sorry, can you spell it out for me?
Where is the 'head'. In the php or the htm??

Thanks.

Dennis
08-13-2003, 03:54 PM
<body>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="15; URL=submitpage.html">
</head>
<body>
...
</body>

:)


simple? :)

mimpoz
08-13-2003, 04:30 PM
Correct me if i'm wrong, but it sounds like i'm meant to put it in the php: 'in the hallo.php put this in the head'.
}:-)

petervazed
08-13-2003, 04:43 PM
Originally posted by mimpoz
Correct me if i'm wrong, but it sounds like i'm meant to put it in the php: 'in the hallo.php put this in the head'.
}:-)

Yep....
but your hallo.php -now- is an empty one, without html code in it.

This hallo.php can be an ordinary html file, and in this file you put the php code
like this:
=========
<html>

<head>
<META HTTP-EQUIV="Refresh" CONTENT="5;URL=index.html"><STYLE TYPE="text/css">
</HEAD>
<body bgcolor
//rest html code//

<?php
$senderemail = $_POST['email'];
$sendername = $_POST['name'];
$sendercolor = $_POST['color'];
$recipient = "vazed@zeelandnet.nl";
$subject = "Test form PHP";
$mailheader = "From: $senderemail\n";
$mailheader.= "Reply-To: $senderemail\n\n";
$message = "Sender's name: $sendername\n";
$message.= "Sender's favorite color: $sendercolor\n\n";
mail($recipient, $subject, $message, $mailheader) or die ("Failure");
?>
<?
print ("Thanks ".$sendername.", for your reply, this page will refresh and bring you back");
?>

</td>
<!-- Row 2 Column 3 -->

// rest of page//
</body>
</html>
==== end====
AND now not save as html but as php file.


:rocker:

petervazed
08-13-2003, 08:13 PM
Found an other option:
header

Your hallo.php can stay empty.

Like this:

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "vazed@zeelandnet.nl", "Feedback Form Results", $message, "From: $email" );
header( "Location: http://members.lycos.nl/vazed/thankyou.html" );
?>

But watch the last line: header
It will bring your visitor to the page you want.

Info header:
http://www.thesitewizard.com/archive/feedbackphp.shtml

:rocker:

mimpoz
08-13-2003, 09:06 PM
thanks a lot!

mimpoz
08-13-2003, 10:27 PM
seeing that you're so helpful-how about this:
How can I send this email to a few recipients??

Let me guess:
<?php
$senderemail = $_POST['email'];
$sendername = $_POST['name'];
$senderstory = $_POST['story'];
$recipient = "abc@optonline.net"; <<here
$recipient2 = "def@optonline.net"; <<& here??
$subject = "Here is a Shmubmission";
$mailheader = "From: $senderemail\n";
$mailheader .= "Reply-To: $senderemail\n\n";
$message = "Sender's name: $sendername\n";
$message .= "Sender's Story: $senderstory\n\n";
mail($recipient, $subject, $message, $mailheader) or die ("Failure"); <<do I have to add anything here???
header( "Location: http://theknish.com/subThank.htm" );
?>

petervazed
08-14-2003, 08:51 PM
Is it working?

You can use to twice or
CC and/or BCC

See the attachment.

This is a tut with links and at the bottem
of the file the to an CC code.


:cool:

mimpoz
08-25-2003, 04:33 PM
Just back from vacation...

I'm trying it out and it's now sending 3 emails to the same location. What's wrong??

<?php
$senderemail = $_POST['email'];
$sendername = $_POST['name'];
$senderstory = $_POST['story'];
$recipient = "qwert@qwerty.net";
$subject = "Here is a Shmubmission";
$mailheaders = "From: $senderemail\n";
$mailheaders = "Bcc: asdf@asdf.com\n";
$mailheaders = "Reply-To: $senderemail\n\n";
$message = "Sender's name: $sendername\n";
$message .= "Sender's Story: $senderstory\n\n";
mail($recipient, $subject, $message, $mailheaders) or die ("Failure");
header( "Location: http://theknish.com/subThank.htm" );
?>