How to create Login app

Hello everyone, I was creating a login application for my app, but ran into a few issues. I have my text entry box under the createRecord so anything typed in these are saved as a username or password in my data set. I then will call upon this data when a user tries to then login to the app. I have a syntax error on line 7 for some reason and my data is being recorded as “”"" instead of what is typed in. Any help would be greatly appreciated and once this is resolved anyone can reuse this code in their projects :slight_smile:

onEvent("toHome1", "click", function() {
  setScreen("screen1");
});
//Code for Login
onEvent("signUp", "click", function() {
  setScreen("signUpScreen");
  createRecord("Logininfomation", {Username:(getText("txtboxUsername")),Password:(getText("txtboxPassword")), function(record){
    }
  });
});
onEvent("login", "click", function() {
  setScreen("loginScreen");
});
onEvent("buttonlogin2", "click", function() {
  readRecords("Logininfomation", {}, function(records) {
  for(var i=0; i < records.length; i++) {
    if (getText("txtboxUsername") == (records[i]).Username && getText("txtboxPassword") == (records[i]).Passwords) {
      setScreen("homePage");
    }
    }
  });
  
  
});

Welcome there,

Would you mind sharing more information? Specifically, a link to all of the code would be helpful. It is very difficult to help when we do not know any of the functions used in your code.

Syntax-wise, the only thing that stands out is:

The object literal is not closed, and I am curious as to why the property values are wrapped in parentheses.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Hope this helps

Thank you for getting back to me! Sorry about the formatting. My teacher told me wrap the property values, but I don’t know why. This is the link to my project "Code.org - App Lab "

It still looks like you have not closed off your object literal - you have 1 too few }

I have figured it all out by myself, thank you for the help

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.