Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I am writing some code to allow users to unsubscribe from our public newsletter. In the (personalized) URL that I send along with the newsletter three parameters are stored:
'act' containing fixed value 'afmelden' (unsubscribe)
'actid' containing a key
'email' containing the email address that is unsubscribing. The key must match the key stored in the database for this email address. If not we will not unsubscribe the user.

The URL looks as follows:
Code: Select all
https://www.example.com/tools/unsubscribe.php?act=afmelden&email=mail@example.com&actid=9923hhb89s2

In my code I am trying to catch the act, actid and email parameters.
But I am unsuccessful: nothing is getting through.
Please see below to get a rough idea of how I built up the code of unsubscribe.php. I am getting the params with gpc then displaying them on the screen for debug purposes: nothing is shown.

What am I doing wrong?

Code: Select all
<cms:if success >
    <!-- sorry to see you go message -->
    <cms:if success = 'NOK' >
        <!-- something went wrong: internal message to manually unsubscribe this user -->
    </cms:if>      
<cms:else />
    <!-- now the real work -->
    <cms:set action="<cms:gpc 'act' method='get'/>" />
    <cms:set activationid="<cms:gpc 'actid' method='get'/>" />
    <cms:set email="<cms:gpc 'email' method='get'/>" />      
   
    act: <cms:show action /><br />
    actid: <cms:show activationid /><br />
    email: <cms:show email /><br />
         
    <cms:if action='unsubscribe' >
        <!-- check email and actid, if OK then unsubscribe this user -->
        <!-- if all went ok than success = 'OK' otherwise it is 'NOK' -->
        <cms:set success = "<cms:show success />" />
        <cms:redirect k_page_link />   
    </cms:if>
</cms:if>
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
I am getting the params with gpc then displaying them on the screen for debug purposes: nothing is shown.

I tried only the following part of your code supplying the sample querystring parameters to the URL -
Code: Select all
<cms:set action="<cms:gpc 'act' method='get'/>" />
<cms:set activationid="<cms:gpc 'actid' method='get'/>" />
<cms:set email="<cms:gpc 'email' method='get'/>" />     

act: <cms:show action /><br />
actid: <cms:show activationid /><br />
email: <cms:show email /><br />

- and the passed parameters were outputted just fine. So the code is correct.
You need to look out for some logical error; I'd suspect following block of your code is never getting getting executed at all -
Code: Select all
<cms:if success >

<cms:else />
    .. check if this part of the code is ever reached ..
</cms:if>

First make sure it does and then proceed with putting any action within it.

Hope this helps.
Hi KK, yes I confirm it is executed. I know that since I see the "act: " etc on the screen. Could it then be some server setting preventing these params coming through? Or htaccess settings? (I used the htaccess as generated by Couch).
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
Code is executed, as I said. However, it just refuses to work. Created a new page. Now it works. Puzzles me why, but it's a fact. Must be some webserver (Apache) hassle...
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
4 posts Page 1 of 1
cron