jedifunk
10-15-2003, 01:41 PM
Hey all;
I'm trying to setup a simple email signup database using PHP. But I can't get it to record the email addresses in the .dat file. Any help is really appreciated. Heres what I've got so far.
Ok, the input text field is inside an MC (newsMC) which is on the main stage. One frame 1 of newsMC I have the following AS:
// Create a External Variable Object
newsletter_vars = new LoadVars();
newsletter_request = function () {
var emailvalidate = newsletterEmail.text; // Grab "emailField" text value for validation
if (emailvalidate.indexOf("@") == -1 || emailvalidate.indexOf(".") == -1) { // Parse "emailvalidate" for required email characters "@" and "."
trace("Invalid E-mail"); // Debug Prompt for check parse function correct
yesNo = "Invalid Address";
break; // Kill function
} else { // if "emailvalidate" parse finds "@" and "."
trace("Valid E-mail. Processing Form"); // Debug Prompt
newsletter_vars.submit=true;
newsletter_vars.supplied_email = newsletterEmail.text; // State new Variable for "newsletter_vars"
newsletter_vars.sendAndLoad("newsletter_handle.php", newsletter_vars, "GET"); // Finally, send (and load) "newsletter_vars" variables to Server Side Script
yesNo = "Thanks for joining!";
eNews = "";
}
}
this.joinBtn.onRelease = newsletter_request; // Button Event. Call function on Submission
//Create Return Key Listner
submit_listener = new Object();
submit_listener.onKeyDown = function () {
if (Key.isDown(Key.ENTER)) {
trace ("Enter is depressed");
newsletter_request;
}
}
Key.addListener(submit_listener);
stop();
Now, this is what I have in my PHP script (newsletter_handle.php) on the server:
<?php
function send_reply($vars) {
mail($vars, "TableTurns newsletter request received", "Thank You for subscribing to the TableTurns newsletter. Please do not respond to this email, as it is an auto-response confirmation of your subscription to the newsletter. The newsletter will keep you up to date on all things happening at TableTurns.com, including newly released albums. Once again, we thank you for your support of TableTurns.", "From: dbbt@tableturns.com");
echo "&mailsent=true";
}
function register ($addy) {
// echo "$supplied_email is the email sent";
$newsletter_file = "subscribers.dat";
if (!($fp = fopen($newsletter_file, "r"))) die ("&write_status=failed");
$temp = fread($fp,1000);
fclose($fp);
// Explode/Split Email Address to check address matches
$check = explode("|",$temp);
for($i=0;$i<count($check);$i++) { // Loop through them all
if ($addy == $check[$i]) {
die ("&addres_exist=true"); // if equal kill function... users has already subscribed
}
}
$temp2 = $temp . $addy . "|";
$fp = fopen($newsletter_file, "w");
fwrite ($fp, $temp2);
fclose($fp);
send_reply($addy);
}
switch($submit) {
case "true":
register($supplied_email);
break;
default:
die;
break;
}
?>
Also on the server is a file called subscribers.dat which should hold all the email addresses. But when I copy this to my HD and open it, its a blank document.
Any thoughts on this? Thanks to any and all for help.
I'm trying to setup a simple email signup database using PHP. But I can't get it to record the email addresses in the .dat file. Any help is really appreciated. Heres what I've got so far.
Ok, the input text field is inside an MC (newsMC) which is on the main stage. One frame 1 of newsMC I have the following AS:
// Create a External Variable Object
newsletter_vars = new LoadVars();
newsletter_request = function () {
var emailvalidate = newsletterEmail.text; // Grab "emailField" text value for validation
if (emailvalidate.indexOf("@") == -1 || emailvalidate.indexOf(".") == -1) { // Parse "emailvalidate" for required email characters "@" and "."
trace("Invalid E-mail"); // Debug Prompt for check parse function correct
yesNo = "Invalid Address";
break; // Kill function
} else { // if "emailvalidate" parse finds "@" and "."
trace("Valid E-mail. Processing Form"); // Debug Prompt
newsletter_vars.submit=true;
newsletter_vars.supplied_email = newsletterEmail.text; // State new Variable for "newsletter_vars"
newsletter_vars.sendAndLoad("newsletter_handle.php", newsletter_vars, "GET"); // Finally, send (and load) "newsletter_vars" variables to Server Side Script
yesNo = "Thanks for joining!";
eNews = "";
}
}
this.joinBtn.onRelease = newsletter_request; // Button Event. Call function on Submission
//Create Return Key Listner
submit_listener = new Object();
submit_listener.onKeyDown = function () {
if (Key.isDown(Key.ENTER)) {
trace ("Enter is depressed");
newsletter_request;
}
}
Key.addListener(submit_listener);
stop();
Now, this is what I have in my PHP script (newsletter_handle.php) on the server:
<?php
function send_reply($vars) {
mail($vars, "TableTurns newsletter request received", "Thank You for subscribing to the TableTurns newsletter. Please do not respond to this email, as it is an auto-response confirmation of your subscription to the newsletter. The newsletter will keep you up to date on all things happening at TableTurns.com, including newly released albums. Once again, we thank you for your support of TableTurns.", "From: dbbt@tableturns.com");
echo "&mailsent=true";
}
function register ($addy) {
// echo "$supplied_email is the email sent";
$newsletter_file = "subscribers.dat";
if (!($fp = fopen($newsletter_file, "r"))) die ("&write_status=failed");
$temp = fread($fp,1000);
fclose($fp);
// Explode/Split Email Address to check address matches
$check = explode("|",$temp);
for($i=0;$i<count($check);$i++) { // Loop through them all
if ($addy == $check[$i]) {
die ("&addres_exist=true"); // if equal kill function... users has already subscribed
}
}
$temp2 = $temp . $addy . "|";
$fp = fopen($newsletter_file, "w");
fwrite ($fp, $temp2);
fclose($fp);
send_reply($addy);
}
switch($submit) {
case "true":
register($supplied_email);
break;
default:
die;
break;
}
?>
Also on the server is a file called subscribers.dat which should hold all the email addresses. But when I copy this to my HD and open it, its a blank document.
Any thoughts on this? Thanks to any and all for help.