Adding profile fields

Advanced Security - PHP Register/Login System Advanced Security - PHP Register/Login System September 11, 2020
Login to reply
Milos Stojanovic Support Agent
1 hour ago


The problem is most likely with the confirmation email, probably because your server is either not configured to send emails or, if you are using an external SMTP server, the app is unable to connect to it. 

I'll recommend you to check the Developer Guide to see how you can debug AJAX requests and then use that technique to see what is wrong with the registration.

Kind regards,

Michael Coy
14 hours ago

Hi Again. I am experiencing an issue. See attached. After registering the
user is added to the DB but the button just says creating account.. and
nothing happens. What could be the problem?

Michael Coy
1 week ago

Thanks Milos for the detailed explanation. I will try and sort it out now.

Milos Stojanovic Support Agent
1 week ago

Hey Michael.

Here is the high-level overview of what you need to do, and I will suggest you to go through the code for existing fields to see how it works:

1) You need to add the HTML for that new input field that you want to add.

The HTML for the user details form is within the profile.php file, so just edit that file and add one more text input field there. Make sure that you set the "name" attribute for it since you will use that in the next step. For our example, let's say that you added "date_of_birth" as a name attribute for this field

2) Update the JavaScript file that's responsible for sending the form data to the server using AJAX.

The file that you need to edit is "assets/js/app/profile.js" and you'll need to extend the handler for "#update_details" button click which starts on line 44. All you need to do is to add one more item into the "details" object. The key there should be the name of your database column (let's say you also named it "date_of_birth") and the value is the value for your newly added form element.

Here is an example:

details: {
    first_name: form['first_name'].value,
    last_name: form['last_name'].value,
    address: form['address'].value,
    phone: form['phone'].value,
    date_of_birth: form['date_of_birth'].value, // <-- this is what we added

And that's really it, it will then be sent to the ASAjax.php file and trigger the "updateDetails" method from ASUser class, which will then update the data in the database.

Kind regards,

Michael Coy
1 week ago

Could you explain how I could add additional user_details fields. For example: Date of Birth. I cannot work out how to save that to the database. I have created the necessary column in the DB.