Newsletter signup action
Archived from the Xataface Users forum.
tomhousley — Thu Oct 28, 2010 10:05 am
Hi Steve,
On xataface.com there is the form to sign up to the newsletter:
- Code: Select all
- `<form action="admin.php" method="post" onsubmit="if (!this.email.value.match(/^[a-z0-9A-Z.\-_]+@[a-z0-9A-Z.\-]+$/)){alert('Please enter a valid email address.');return false;} return true;">
</form>`
Would it be possible for you to upload the maillist_signup.php and any related code so I may implement the same?
Many thanks, Tom
shannah — Fri Oct 29, 2010 2:38 pm
Here’s the custom action:
- Code: Select all
<?php class actions_maillist_signup { function handle(&$params){ if ( !@$_POST['email'] ) return PEAR::raiseError("No email address supplied"); if ( !preg_match('/^[a-z0-9A-Z.\-_]+@[a-z0-9A-Z.\-]+$/', $_POST['email']) ) return PEAR::raiseError("Please enter a valid email address"); $record = new Dataface_Record("maillist_optin", array()); $record->setValue('email', $_POST['email']); $res = $record->save(); if ( PEAR::isError($res) ){ header("Location: admin.php?-action=home&--msg=".urlencode("Error occurred trying to subscribe to maillist: ".$res->getMessage())); exit; } else { mail('email@example.com','New Xataface maillist signup', $record->val('email').' has signed up for the xataface newsletter.'); header("Location: admin.php?-action=home&--msg=".urlencode("Thank you for subscribing to the Xataface maillist. You can opt out at any time by following the link provided in emails from the list")); exit; } } }
tomhousley — Mon Nov 01, 2010 10:02 am
Thank you Steve.
In the process of creating actions for confirming email address etc.
Once complete, I will post them here.
Cheers, Tom