Redirect does not work after saving form data to database.

2010-06-16 Thread xpo60rj
I'm new to cakephp. I'm trying to build a newsletters subscription
field that is placed in my footer element. I can not get my page to
redirect back to home after submitting form data to the database along
with email notification. The data is saved to the database and I do
get my confirmation email. Instead of redirecting back to home I
constantly get redirected to a page I have no control over
(example.com/subscriptions/add). What am I doing wrong?

Model (subscription.php):

class Subscription extends AppModel
{
#Define the name of the Model
var $name = Subscription;
var $validate = array(
'email' = array(
'rule' = array('email', true),
'message' = 'Please supply a valid email address.'
)
);
}


Controller (subscriptions_controller.php):

class SubscriptionsController extends AppController
{
var $name = Subscriptions;
var $components = array('Email');


function index() {
$this-set('subscriptions', $this-Subscription-find('all'));
}
function add() {
if (!empty($this-data)) {
if ($this-Subscription-save($this-data)) {
$this-Email-to = $this-data['Subscription']['Email'];
$this-Email-subject = 'Subscription Request';
$this-Email-from = 't...@example.com';
$this-Email-send('TEST');
$this-redirect('/', null, true);
   }
 }
 }
}

View (Subscriptions.ctp):

echo $form-create('Subscription');
echo $form-input('Email', 'Email', array(
'type' = 'varchar'
));
echo $form-end('Submit');

I have this view inside an my footer element using this:

echo $this-element('subscriptions');

This is the contents of the subscriptions/add page i keep getting
redirected to:

To: t...@example.com
From: t...@example.com
Subject: Subscription Request
Header:

From: t...@example.com
X-Mailer: CakePHP Email Component
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bitParameters:

Message:

TEST

1

Can someone help me get this to redirect or how can i control the page
that is being rendered at subscriptions/add? I've tried making an
add.ctp inside a subscriptions folder under views, but that doesnt
seem to do anything.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Redirect does not work after saving form data to database.

2010-06-16 Thread xpo60rj
I'm new to cakephp. I'm trying to build a newsletters subscription
field that is placed in my footer element. I can not get my page to
redirect back to home after submitting form data to the database along
with email notification. The data is saved to the database and I do
get my confirmation email. Instead of redirecting back to home I
constantly get redirected to a page I have no control over
(example.com/subscriptions/add). What am I doing wrong?

Model (subscription.php):

class Subscription extends AppModel
{
#Define the name of the Model
var $name = Subscription;
var $validate = array(
'email' = array(
'rule' = array('email', true),
'message' = 'Please supply a valid email address.'
)
);
}


Controller (subscriptions_controller.php):

class SubscriptionsController extends AppController
{
var $name = Subscriptions;
var $components = array('Email');


function index() {
$this-set('subscriptions', $this-Subscription-find('all'));
}
function add() {
if (!empty($this-data)) {
if ($this-Subscription-save($this-data)) {
$this-Email-to = $this-data['Subscription']['Email'];
$this-Email-subject = 'Subscription Request';
$this-Email-from = 't...@example.com';
$this-Email-send('TEST');
$this-redirect('/', null, true);
   }
 }
 }
}

View (Subscriptions.ctp):

echo $form-create('Subscription');
echo $form-input('Email', 'Email', array(
'type' = 'varchar'
));
echo $form-end('Submit');

I have this view inside an my footer element using this:

echo $this-element('subscriptions');

This is the contents of the subscriptions/add page i keep getting
redirected to:

To: t...@example.com
From: t...@example.com
Subject: Subscription Request
Header:

From: t...@example.com
X-Mailer: CakePHP Email Component
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bitParameters:

Message:

TEST

1

Can someone help me get this to redirect or how can i control the page
that is being rendered at subscriptions/add? I've tried making an
add.ctp inside a subscriptions folder under views, but that doesnt
seem to do anything.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en