Forum

Thread tagged as: Question, Forum, Members
Drew McLellan

Drew McLellan 2638 points
Perch Support

How do you know this is a validation error?

I wrote the software :-)

If you're logged in then the issue looks like a token mismatch. Do you see a token in the hidden field when you view source on the form?

Drew,

Yes it was the token. My editor has an option to format (tidy up) the source code. I used it on my template file and, unfortunately, it breaks the token input field onto two lines, causing the missmatch! Going to tidy up the code myself in future.

Thanks for your help again.

Haha!

Yes, I can see a token but can't seem to find any problems with it - from the form point of view. I can view this in the website source.

<input type="hidden" name="cms-form" value="cHJvZmlsZTpwZXJjaF9tZW1iZXJzOi90ZW1wbGF0ZXMvY29udGVudC9tZW1iZXJzL2Zvcm1zL3Byb2ZpbGUuaHRtbDoxNTA2MDc1MTA1">
<input id="form2_token" name="token" type="hidden">

Hi Connor,

My token code in the template looks like this:

   <input id="token" name="token" value="<perch:members id="token" />" type="hidden">
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, so your token field has no value? That would explain it.

I don't understand :') How do I know what the token is?

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you have this:

<input id="form2_token" name="token" type="hidden">

then there's no value set, so when the token is checked it will fail. You don't know what it is - that's sort of the point. The system generates it and it prevents a whole class of hacks.

Are these the default templates you're using?

Ah... I see. That makes sense.

I am using the default templates, yes.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is everything else working as expected?

If by everything else, you mean with Perch, then yes. The other forms are working fine - it's just this one.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Including other aspects of Members?

Oh right. Yes, everything else seems to be working for members at present.

Hi Patricia,

Would you be able to post your profile.html template code? I really can't seem to get mine to work. Don't know whether it is because of the template or something else.

Hi guys,

Any more ideas on my problem here?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you still talking with Patricia or are you looking for help from me?

Patricia doesn't seem to be very active just now. If you are able to help that would be great. I just can't figure out what the issue is.

Hi Connor,

Sorry, I have been away. As Drew says it looks like you do not have a value set in your template for the "token". The default members template looks like this in regards to the token: <perch:input type="hidden" id="token" />

I have changed it so that it gets a VALUE from the logged in member: <input id="token" name="token" value="<perch:members id="token" />" type="hidden"> You will notice that the value is now populated with a members token id.

Hope this helps.

Regards, Patricia

Thanks Patricia. I shall try something along the same lines tonight. Should the token be populated already or did you have to make this edit to make it do so? Otherwise I can't figure out what I've done wrong.

No the template file profile.html just has: <perch:input type="hidden" id="token" />

Have you taken a copy of the member template folder files (from addons/perch_members/templates) and put them in your perch/templates/ folder? You should do this before you work on them.

Regards, Patricia

I have taken a copy of them. I tried your code and still can't seem to get it to work.