Newsletter signup action

A place for users and developers of the Xataface to discuss and receive support.

Newsletter signup action

Postby 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;">
   <input type="hidden" name="-action" value="maillist_signup"/>

   <input type="text" name="email" size="15" />
   <input type="submit" value="Sign up" />
</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
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Re: Newsletter signup action

Postby 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;
      }
   }   
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Newsletter signup action

Postby 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
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 44 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved