| View previous topic :: View next topic |
| Author |
Message |
ebba
Joined: 16 Aug 2004 Posts: 25
|
Posted: Mon Sep 19, 2005 11:39 am Post subject: Registration to newsletter |
|
|
| I have a page where people can submit to a newsletter. At this point they must send an email to me whith their email address. Can I in somehow make a php-script so they only can enter their email address and I get it via e-mail? |
|
| Back to top |
|
 |
|
|
webmaster Site Admin

Joined: 17 Aug 2004 Posts: 3642 Location: Sweden
|
Posted: Mon Sep 19, 2005 11:59 am Post subject: Re: Registration to newsletter |
|
|
Try something like this:
PHP: <?php
if(isset($_POST['submit'])) {
$to = "your@email.com";
$subject = "Registration to newsletter";
$message = $_POST['email'];
mail($to, $subject, $message);
echo "You are now registered to the newsletter!";
} else { ?>
<form method="post">
Your e-mail address: <input type="text" name="email" />
<input type="submit" name="submit" value="send the mail" />
<?php } ?>
|
|
| Back to top |
|
 |
Protege 50+ Club
Joined: 19 Sep 2005 Posts: 68 Location: Scotland
|
Posted: Mon Sep 19, 2005 12:08 pm Post subject: Re: Registration to newsletter |
|
|
Remember: before you go adding that to a 'live' site it needs some security. If it gets abused then you're up a certain creek without a paddle.  |
|
| Back to top |
|
 |
webmaster Site Admin

Joined: 17 Aug 2004 Posts: 3642 Location: Sweden
|
Posted: Mon Sep 19, 2005 12:27 pm Post subject: Re: Registration to newsletter |
|
|
| Protege wrote: |
Remember: before you go adding that to a 'live' site it needs some security. If it gets abused then you're up a certain creek without a paddle.  |
Exactly, some use forms like this to send out spam. I'm not very good at e-mail security and what's possible to do with email-injections in forms. But this is what I use, are there anything I've missed?
PHP: <?php
$message = str_replace(array("\\","Content-Type:","bcc:","cc:","MIME-Version:",
"Content-Transfer-Encoding:","%"),"",$message);
?>
|
|
| Back to top |
|
 |
Phate 500+ Club

Joined: 21 Nov 2004 Posts: 818 Location: 127.0.0.1
|
Posted: Mon Sep 19, 2005 6:51 pm Post subject: Re: Registration to newsletter |
|
|
| what exactly does that do? |
|
| Back to top |
|
 |
webmaster Site Admin

Joined: 17 Aug 2004 Posts: 3642 Location: Sweden
|
Posted: Mon Sep 19, 2005 11:59 pm Post subject: Re: Registration to newsletter |
|
|
| Phate wrote: |
| what exactly does that do? |
If someone writes "Content-Type:", "bcc:","cc:", "MIME-Version:", "Content-Transfer-Encoding:" or "%" in the message, They will be removed. |
|
| Back to top |
|
 |
Phate 500+ Club

Joined: 21 Nov 2004 Posts: 818 Location: 127.0.0.1
|
Posted: Tue Sep 20, 2005 5:44 am Post subject: Re: Registration to newsletter |
|
|
oh!
thanks very much! |
|
| Back to top |
|
 |
|