Forum

Thread tagged as: Question, Problem, Error

User profile updates

I have a problem in my implementation, gonna try to explain here. Maybe someone can help me.

Created a form

 <perch:form id="profile" method="post" app="perch_members" >
    <perch:success show-form="true">
                <div id="uanotice" class="col-sm-6 col-sm-offset-3 s5paddingform text-center">
                    <p>Your details have been updated.</p>
                </div>                
            </perch:success>
                   <perch:input type="text" placeholder="First Name *" class="form-control" id="first_name" required="true" label="First name"/>
                    <perch:error for="first_name" type="required" >First Name *</perch:error>
                </div>
                <div class="col-sm-3 s5paddingform">
                    <perch:input type="text"  class="form-control" placeholder="Last Name *"  id="last_name" required="true" label="Last name" />
                    <perch:error for="last_name" type="required" >Last Name *</perch:error>
            <div class="row s5paddingform">
                <div class="col-sm-6 col-sm-offset-3 s5btnpaddingform"> 
                    <perch:input type="submit" name="submit_profile" class="btn btn-base btn-submit" value="UPDATE ACCOUNT" />
                    <perch:input type="hidden" id="token" />
                </div>
            </div></perch:form>

When I click submit I get the message "Your details have been updated." But from this point if I change something else and click submit nothing happens, no message and data is not updated.

Note: There is no indication of javascript error in the page in all of this process, using perch debug also does not display any error

How can I have the profile updated again and again after the first post? Seems there is a problem in my code?

Thanks

Anderson Almeida

Anderson Almeida 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What does the debug output at the point where it doesn't work?

Hi Drew,

Just as an extra information I have tested the example which comes with Perch in the Members zip file, it has same behavior (html in the bottom of this reply).

The default of the example doesn't have the show-form in the perch:sucess so it hides the form and user cannot change it again until refresh the page to see the form.

But in the example if we change to <perch:success show-form="true"> and after the first successful change with the success message if we try to change again nothing happens the page just reloads without changing the data.

Follows my debug:

1 First page load

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='9b9aa8814250804177681e9ec4cf68be871f12b7' AND sessionHttpFootprint='f065f3c83cb65bb1113a9345aad441635fa6e6b8' AND sessionExpires>'2015-06-12 12:23:55' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/dashboard.php' LIMIT 1
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/dashboard.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/members/forms/update_account.html

2 First changes post got "Your details have been updated." this first post works pretty well

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='9b9aa8814250804177681e9ec4cf68be871f12b7' AND sessionHttpFootprint='f065f3c83cb65bb1113a9345aad441635fa6e6b8' AND sessionExpires>'2015-06-12 12:25:12' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/dashboard.php' LIMIT 1
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_members WHERE memberID='6' LIMIT 1
UPDATE perch2_members SET memberProperties='{\"first_name\":\"Anderson\",\"last_name\":\"X \",\"company\":\"X\",\"country\":\"X\",\"addressline1\":\"X\",\"addressline2\":\"X C\",\"town\":\"X\",\"county\":\"X\",\"postcode\":\"X\",\"vatno\":\"X\",\"acceptterms\":\"true\",\"reference\":\"How did you hear from us?\",\"details\":\"\",\"token\":\"a41a61305609652be2200ae4d14be6b55ea479fe\",\"submit_profile\":\"UPDATE ACCOUNT\"}' WHERE memberID=6
No ids to log.
SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='6' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2015-06-12 12:25:00')
INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('e8a85295c10e27958e1e4710c73c27448c9f3476','2015-06-17 12:25:12','f065f3c83cb65bb1113a9345aad441635fa6e6b8','6','a:24:{s:10:\"first_name\";s:8:\"Anderson\";s:9:\"last_name\";s:8:\"Y \";s:7:\"company\";s:4:\"Y\";s:7:\"country\";s:6:\"Y\";s:12:\"addressline1\";s:15:\"Y\";s:12:\"addressline2\";s:4:\"Y Y\";s:4:\"town\";s:8:\"Y\";s:6:\"county\";s:2:\"Y\";s:8:\"postcode\";s:5:\"Y\";s:5:\"vatno\";s:11:\"Y\";s:11:\"acceptterms\";s:4:\"true\";s:9:\"reference\";s:25:\"How did you hear from us?\";s:7:\"details\";s:0:\"\";s:5:\"token\";s:40:\"41088031185033bc756f54e0a464d145b7119cee\";s:14:\"submit_profile\";s:14:\"UPDATE ACCOUNT\";s:8:\"memberID\";s:1:\"6\";s:14:\"memberAuthType\";s:6:\"native\";s:12:\"memberAuthID\";s:1:\"6\";s:11:\"memberEmail\";s:38:\"anderson.@Removed\";s:14:\"memberPassword\";s:34:\"$P$BhaWhEtReIKQc6d8Ys2STefzAWQeU20\";s:12:\"memberStatus\";s:6:\"active\";s:13:\"memberCreated\";s:19:\"2015-05-27 14:40:57\";s:13:\"memberExpires\";N;s:4:\"tags\";b:0;}')
DELETE FROM perch2_members_sessions WHERE sessionExpires < '2015-06-12 12:25:12'
DELETE FROM perch2_members_sessions WHERE sessionID='9b9aa8814250804177681e9ec4cf68be871f12b7'
SELECT * FROM perch2_members_sessions WHERE sessionID='e8a85295c10e27958e1e4710c73c27448c9f3476' AND sessionHttpFootprint='f065f3c83cb65bb1113a9345aad441635fa6e6b8' AND sessionExpires>'2015-06-12 12:25:12' LIMIT 1
User is logged in
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/dashboard.php' OR regionPage='*' ORDER BY regionPage DESC
Using template: /templates/members/forms/update_account.html

3 Second changes post got no changes after post

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='e8a85295c10e27958e1e4710c73c27448c9f3476' AND sessionHttpFootprint='f065f3c83cb65bb1113a9345aad441635fa6e6b8' AND sessionExpires>'2015-06-12 12:29:35' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/dashboard.php' LIMIT 1
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Array
(
    [all] => login
)
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/dashboard.php' OR regionPage='*' ORDER BY regionPage DESC
Using template: /templates/members/forms/update_account.html

Clean test from Perch Members example, just added show-form="true" has same behavior, does not change data after the first change ahead

<perch:form id="profile" method="post" app="perch_members">

    <div>
        <perch:label for="first_name">First name</perch:label>
        <perch:input type="text" id="first_name" required="true" label="First name" />
        <perch:error for="first_name" type="required">Please add a your name</perch:error>
    </div>

    <div>
        <perch:label for="last_name">Last name</perch:label>
        <perch:input type="text" id="last_name" required="true" label="Last name" />
        <perch:error for="last_name" type="required">Please add a your name</perch:error>
    </div>

    <div>
        <perch:label for="email">Email</perch:label>
        <perch:input type="email" id="email" required="true" placeholder="you@company.com" />
        <perch:error for="email" type="required">Please add a your email address</perch:error>
        <perch:error for="email" type="format">Please check a your email address</perch:error>
    </div>

    <div>
        <perch:input type="submit" value="Save" />
        <perch:input type="hidden" id="token" />
    </div>

    <perch:success  show-form="true">
        <p>Your details have been updated.</p>
    </perch:success>

</perch:form>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, I'll see if I can reproduce it.

thanks for the help still no success here

Drew McLellan

Drew McLellan 2638 points
Perch Support

No success here either. Is there anything else you can tell me?

Seems the form can be submitted only once, even the example \perch\addons\apps\perch_members\profile.html has the same behaviour when we set perch:success show-form="true".

We have implemented in another way.

Thanks

I ran into the behaviour described today.

It's because when a member profile is updated, the session data is refreshed and the new member session token doesn't match the form hidden field <perch:input type="hidden" id="token" />.

As a workaround, I grabbed the token at the top of my page with PerchSystem::set_var('token', perch_member_get('token')); and replaced the hidden field in the template with <input id="token" name="token" value="<perch:members id="token" />" type="hidden">.

Seems to work with no problems.