»

Main >> Geek Out >> phplist and flash

 
Profile
avatar
phplist and flash
Posted By: obie on 03-07-2008 3:35 pm
Posts: 10
  Guv
I just had to tell someone about this thing that i managed to work out because when i tried to post on the phplist forums i was told that i couldn't because i had posted a url and i couldn't post one in the first 10 posts / 7 days. RIDICULOUS!

Anyway, I grabbed the variables that the phplist subscribe form sends via the POST method using Charles which is a proxy that intercepts all the wonderful bits of info that your browser is sending out and put them into my flash form validation script.


function validateForm ():Void {
var error_msg = "";

if ((!nl_email || nl_email == "email address") && (!nl_name || nl_name == "name")) {
error_msg += "Please enter name\r";
error_msg += "Please enter email address\r";
}
if (!nl_name || nl_name=="name") error_msg += "Please enter name\r";
if (!nl_email || nl_email=="email address") error_msg += "Please enter email address\r";
if (!(!nl_email || nl_email=="email address")) {
if ((nl_email.indexOf("@",0)0)) error_msg += "Please check email address\r";
}

if (!error_msg) {
var emailForm:LoadVars = new LoadVars();
emailForm.email = nl_email;
emailForm.emailconfirm = nl_email;
emailForm.htmlemail = "1";
emailForm.attribute1 = nl_name;
emailForm["list[1]"] = "signup";
emailForm["listname[1]"] = "Newsletter";
emailForm.VerificationCodX = "";
emailForm.subscribe = "Subscribe to the Selected Newsletters";
//replace the url below with your own url path
emailForm.sendAndLoad("http://mydomain.com/phplist/?p=subscribe&id=1", emailForm, "POST");
//this.loadVariables("nl_signup.php","POST");
this.nextFrame();
} else {
nl_error = error_msg;
}
}



Note:

  • nl_name is the username field in the flash movie

  • nl_email is the email field in the flash movie

  • id=1 is the id of the newsletter

  • attribute1 is an extra attribute i set up in the phplist admin panel to take the users name



There, that wasn't so frickin' hard now, was it?



Forum Powered By XDForum Ver. 2.01