It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Registration to newsletter

Moderator: Malcolm

Registration to newsletter

Postby ebba on Mon Sep 19, 2005 10:39 am

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?
ebba
 
Posts: 25
Joined: Mon Aug 16, 2004 7:37 pm

Postby webmaster on Mon Sep 19, 2005 10:59 am

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 } ?>[/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Protege on Mon Sep 19, 2005 11:08 am

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. :wink:
Protege
50+ Club
 
Posts: 67
Joined: Mon Sep 19, 2005 8:05 am
Location: Scotland

Postby webmaster on Mon Sep 19, 2005 11:27 am

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. :wink:
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);
?>[/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Phate on Mon Sep 19, 2005 5:51 pm

what exactly does that do?
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby webmaster on Mon Sep 19, 2005 10:59 pm

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.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Phate on Tue Sep 20, 2005 4:44 am

oh!

thanks very much!
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1


Who is online

Users browsing this forum: No registered users and 0 guests