Hey Everyone-
I would like some help on this script I have been putting it together for my newsletter signup page on my site. This current script below works for writing the client's email address and name into a text file (subscribers.txt). However, it still does not send me an email with the contents of several text boxes on the newsletter signup page. How do I:
#1. Receive an email with all of the info from the form (subject, age, city, etc.)
#2. Have the client's email address in the "from" area on the notification (not anonymous@server.com).
#3. Have email verification on signup to make sure they enter a valid address.
The existing code is below:
------------------------
<?php
// see if newsletter was checked
$email = trim(@$_POST['email'] );
//@suppresses the warning when email is not set
if ( isset($_POST['newsletter']) &&!empty($email) ) {
$filename = 'subscribers.txt';
$name_arr = explode( ' ', $_POST['FullName'] );
$first_name = $name_arr[0];
$file_arr = file($filename);
$found = false;
foreach ($file_arr as $value) {
if (strpos($value, $_POST['email'])!==FALSE ) {
//this change was necessary: check manual for strpos
$found = true;
break;
}
}
if (!$found) {
$fp = fopen($filename, 'a+');//a+ means "create when it's not present"
fwrite($fp, $_POST['email'] . ',' . $_POST['FullName'] . "\n");
fclose($fp);
}
}
// this redirect is whether newsletter was checked or not
$URL = "thankyou-newsletter.html";
header ("Location: $URL");
?>
------------------------
Thanks!
I would like some help on this script I have been putting it together for my newsletter signup page on my site. This current script below works for writing the client's email address and name into a text file (subscribers.txt). However, it still does not send me an email with the contents of several text boxes on the newsletter signup page. How do I:
#1. Receive an email with all of the info from the form (subject, age, city, etc.)
#2. Have the client's email address in the "from" area on the notification (not anonymous@server.com).
#3. Have email verification on signup to make sure they enter a valid address.
The existing code is below:
------------------------
<?php
// see if newsletter was checked
$email = trim(@$_POST['email'] );
//@suppresses the warning when email is not set
if ( isset($_POST['newsletter']) &&!empty($email) ) {
$filename = 'subscribers.txt';
$name_arr = explode( ' ', $_POST['FullName'] );
$first_name = $name_arr[0];
$file_arr = file($filename);
$found = false;
foreach ($file_arr as $value) {
if (strpos($value, $_POST['email'])!==FALSE ) {
//this change was necessary: check manual for strpos
$found = true;
break;
}
}
if (!$found) {
$fp = fopen($filename, 'a+');//a+ means "create when it's not present"
fwrite($fp, $_POST['email'] . ',' . $_POST['FullName'] . "\n");
fclose($fp);
}
}
// this redirect is whether newsletter was checked or not
$URL = "thankyou-newsletter.html";
header ("Location: $URL");
?>
------------------------
Thanks!