|
|
subscribe.php
|
|
|
|
Forum Regular
Join Date: May 2004
Location: France
Status:
Offline
|
|
Hello,
I have a webserver where PHP is installed.
On the footer of this page there is a newsletter subscription box on the right.
The code of the form is:
Code:
<form class="newsletter-form" action="subscribe.php" method="post" name="newsletter">
<fieldset>
<input type="text" size="30" value="" id="newsletter-email" name="newsletter-email">
<input type="submit" class="newsletter-submit" name="send" value="Send">
</fieldset>
</form>
And here is my PHP code:
Code:
<?php
echo 'this is a test';
// test existance variable
$mavariable = $HTTP_POST_VARS['newsletter-email'];
echo $mavariable;
//Si ok envoie mail
//$TO = "[email protected]";
//$h = "From: " . $TO;
//$subject = "Inscription newsletter ";
//$message = $_POST['newsletter-email'];
//mail($TO, $subject, $message, $h);
//Header("Location: thanks.html");
?>
Once the email is written, I'm redirected to thanks.html and I receive an email, but without the email address. Is there anyone who can give me the right php code ? I can pay for this work.
My iChat is [email protected]
thanks
|
|
|
|
|
|
|
|
|
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status:
Offline
|
|
You need another form field to gather their email address... I have the code at home.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: May 2004
Location: France
Status:
Offline
|
|
thanks a lot andi*pandi, would it be possible to send me the code by private message ?
you would help me a lot.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Yes, you need to collect the from address, and you should rewrite the following:
Code:
$mavariable = $HTTP_POST_VARS['newsletter-email'];
As:
Code:
$mavariable = $_POST['newsletter-email'];
As the other way is deprecated and will stop working soon, depending on what version of PHP you are running.
Your code should really include some checks to ensure that the from address is formatted correctly to prevent spam, and whatever you do do NOT change the code to allow the user to enter the "to" address the email is destined for in the public form, as this will open up the form for all kinds of spam abuse. IOW, leave recipient's address printed directly into the code as it is now.
Here is a simple check to ensure that the from address is formatted correctly:
Code:
<?php
if (!preg_match('/^.+?@.+?\..+$/', $_POST['from-form-field'])) {
// invalid email, do something
}
?>
This is a very crude check, but it should help a little.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: May 2004
Location: France
Status:
Offline
|
|
Thanks guys, I figured it's actually a conflict with this js. Don't know yet where is the bug.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
No it's not.
Assuming that you have uncommented these two lines, you are setting the from address to be the same as the to address, there is absolutely no ambiguity about this.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|