Forum
Perch Members / Shop check_email not working
I'm using the form below for shop members to update their name and email address. Obviously if they enter an email address that already exists in the database it won't be updated. I've added the helper
attribute to the email form input (line 20
) and an error message which should tell the user what's going on (line 23
).
When I test by entering an address that's already in the database, the form submits and displays the <perch:success>
content. But the email address hasn't been changed of course.
Any ideas for getting the error message working would be appreciated.
My template code is:
<perch:form id="profile" method="post" app="perch_members" class="standard-styles">
<!-- Hidden inputs at the beginning of the form -->
<perch:input type="hidden" id="token" />
<div class="form-group">
<perch:label for="first_name">First Name</perch:label>
<perch:input type="text" id="first_name" required="true" label="First name" class="form-control" />
<perch:error for="first_name" type="required">Please enter your first name</perch:error>
</div>
<div class="form-group">
<perch:label for="last_name">Last name</perch:label>
<perch:input type="text" id="last_name" required="true" label="Last name" class="form-control" />
<perch:error for="last_name" type="required">Please enter your last name</perch:error>
</div>
<div class="form-group">
<perch:label for="email">Email</perch:label>
<perch:input type="email" id="email" required="true" placeholder="you@company.com" helper="PerchMembers_Members::check_email" class="form-control" />
<perch:error for="email" type="required">Please enter your email address</perch:error>
<perch:error for="email" type="format">Please check a your email address is correct</perch:error>
<perch:error for="email" type="helper">That email address is already in use, please use another</perch:error>
</div>
<perch:input type="submit" value="Update Details" class="btn btn-primary" />
<perch:success>
<div class="alert alert-info">
<p>Your personal details have been successfully updated</p>
</div>
<div class="standard-bottom-margin">
<a href="/members/account" class="btn btn-default">Back To Your Account</a>
</div>
</perch:success>
</perch:form>
<perch:showall />
Perch showall
content is:
ID Value
perch_page_path /members/edit-personal-details.php
first_name Martin Test Two
last_name Jewiss
token 55ba260266d1c6fa562c1a6b1bf266b1b419fc75
memberID 18
memberAuthType native
memberAuthID 18
memberEmail martin3@withverse.uk
memberPassword $P$B7iw.9oDZwsoMkmbg7x63DREvvOROd0
memberStatus active
memberCreated 2017-04-05 17:04:58
memberExpires
tags
Array
(
)
sessionID 0910733006457a9136eeec7aecd3a901a80ca9aa
email martin3@withverse.uk
status active
expires
auth_id 18
id 18
perch_namespace perch:forms
And diagnostics are:
Perch: 2.8.34, PHP: 5.6.9-1+deb.sury.org~trusty+2, MySQL: 5.5.49, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), jw_activity_log (1.0.0), perch_shop_orders (1.0.10), perch_shop_products (1.0.10), perch_shop (1.0.10), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /vagrant/www/kingsdownwater/public_html/perch
PERCH_CORE: /vagrant/www/kingsdownwater/public_html/perch/core
PERCH_RESFILEPATH: /vagrant/www/kingsdownwater/public_html/perch/resources
Image manipulation:
PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: kingsdownwater.dev
DOCUMENT_ROOT: /vagrant/www/kingsdownwater/public_html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Update: I've tried disabling the html5 native validation. The email_chech still does not throw an error when it should.
All that helper does is check that the email address isn't in use by another member. It doesn't stop the user updating their own email address, or from submitting the form without changing their email address.
Understood.
So is there a way I can get the form to display an error message saying that the email address can't be updated if it is already in use by a different member?
Would there be any reason why your member might not have a password?
No, they'll always have a password Drew.
Can you show me the debug output when you get the success message?
Here's the debug output when the success message is shown Drew. FYI
martin3@withverse.uk
is the current email address. The address I entered and wanted to update to ismartin@mpjdesign.ltd.uk
That looks like the output from
<perch:showall />
to me. Can you show me the debug output?Sorry Drew, my mistake. It's been a long few days with not much sleep...
Here's the debug output:
Ahh, I've pieced together the solution looking at the debug output, Drew. It relates to your question about all members having passwords.
__auto__
.perch2_members
table I can see 4 rows withmemberEmail = martin@mpjdesign.com
that were created with the__auto__
password.memberPassword
fields were blank for these members. I thought they would have had the auto generated password recorded.Thanks for your help Drew