Forums

Simple voucher / password form

thiskey 30 Dec, 2009
Hi everyone,

I'd like to use ChronoForms to create a simple voucher / password form. A user enters their e-mail address and a pre-determined password (which is universal). This allows them to go to a re-direct page from which they can download a file. This is for a band with a new EP - they want to give fans a voucher code to imput on the site so they can download the EP for free (everyone else pays). Would also be good if the user receives a thank you e-mail.

It sounds simple but I'm new to ChronoForms and can't work out how to set a password in this way. I've tried validation before I realised it probably isn't the solution.

Once again, the purpose of the form is simply to allow users to proceed to a redirect page if they correctly enter the one universal password. Anyone know how to achieve this?

Thanks!
GreyHead 30 Dec, 2009
Hi thiskey,

The simplest way to do this is to set the form up then in the OnSubmit After box add a little PHP to check the key and show the downlaod url if it is correct.
<?php
$code = JRequest::getString('code', '', 'post');
if ( $code == 'valid_code' ) {
  echo "Here is your download: <a href='http://some_url'>Click here</a>";
} else {
  echo "Sorry, invalid code";
}
?>

Bob
thiskey 30 Dec, 2009
Hi Bob,

Thanks for the reply - I've been trying to get this working but for some reason it isn't.

I've named the text box "code" (the one for the voucher) - I presume this is what you were intending.
I added your code to the "On Submit code - after sending email" box.
When I click submit on the form, it redirects to the redirect page regardless of what I've written in the code textbox, and no message appears.

Any ideas what I'm doing wrong?

Thanks,
Tom
GreyHead 30 Dec, 2009
Hi Tom,

[sendfb][/sendfb]
Bob
thiskey 30 Dec, 2009
Hi Bob, the file is attached.

Thanks very much - I really appreciate it.

Tom
GreyHead 30 Dec, 2009
Hi Tom,

Please remove the Redirect URL to example.com - you don't need it.

Bob
thiskey 30 Dec, 2009
Hi Bob,

I now just get a blank page with "Sorry, invalid code". There's no message on submit, and also (incidentally) I'm not receiving an e-mail (which is the same as before). I'm stuck - any thoughts?

Thanks,
Tom
GreyHead 30 Dec, 2009
Hi Bob,

Works for me if I type valid_code in the code box.

If you want to use some other code then you need to change it in the PHP snippet.

Bob
thiskey 30 Dec, 2009
Bob - I must be having an off day, it's working perfectly. Thanks so much for your help, I really appreciate it.
Tom
This topic is locked and no more replies can be posted.