Newbie in back end
I have a project that im doing for school, but im getting this error everytime and also im having some issues using xampp
I want to make a register form and a login form and also the website will have a session so when i go to other html files its still getting that im in the same email
what i wanted to do is
that i have 4 individual files
1. html file : that has the form tag and the name of each input
2. php file : here im just making error handling to send it to js to change style in css
3. js file: im changing the style so that it makes shake effect if for example the confirm_password is wrong
4 css file
but the problem im always getting this issue
Error: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
and also i dont why for some reason when i try to save any file i need to be in incognito window after saving a just close and the open another windown and mysql keeps crashing
please anyone can help me with this project im so frustrated im trying to self learn but i got no time to do this my deadline is in 3 days15 Replies
I can provide all files if someone wants to check it out
I dont know what im doing ):
If that error is happening in the browser, which I think it is, you’re using JSON.parse() on the PHP file, you said that you’re passing it to JS to style. You just want to handle it as plain text not JSON.
In the event that that error is occurring in XAMPP you’re using json_decode() on the HTML file
Im gonna die please help )::::
Hmm I see
You are missing this from your php file, and I've never actually returned JSON without that header to know what the behaviour is. I can't imagine it would then insert doctype but it could
8 more things:
1. Line 22 of your php file you should not include internal error messages. Just return a status 500 and "Internal server error" and then log that error to a file.
2. Salt your passwords.
3. It's possible for profile picture images to fail uploading.
4. Use HttpOnly for your cookies.
5. Don't use first and last names, just ask for a name. You almost never need to know which part is which, and not everyone wants to give you their last name. You can ask for a name, if you are handling shipping that will be done seperately and again you'd just ask for name. Around the world a lot of naming conventions exist that don't fit first and last, such as East Asian countries having the family name first, and Dutch with things like "van der" between names that don't neatly split up.
6. Consider un-nesting your code, you have 4 levels of indentation and a lot of things happening.
7. Avoid long lines, it's harder to read
8. Expand your variable names, there's no point doing
fname
when you can do the much clearer first_name
Figured I'd make those 9 changes. This code is untested. Just be aware I removed first and last names and replace it with name and username, additionally added a check to make sure usernames were unique
@Skylark Thanks for helping me!
Btw you can get that shake effect with purely css if if’s invalid
They can steal the
shake
animation from my pen https://codepen.io/z-/pen/ZEydQPx
CSS lines 24-43 with the animation
being on line 22. It's very simpleZed Dash
CodePen
[CPC] Dropdown Slots
It slightly stretches the definition of a dropdown, but it's a single input with a finite number of known valid options, that just require a click to g...
I just read through their JS, it looks like they're already using a CSS animation, they're adding and removing a
shake
classMy point was that they could use a pseudo selector to trigger it , :valid or :invalid (not sure where support is for :user-valid :user-invalid yet)
The validity is controlled by the JS
Looks to be pretty good!
https://caniuse.com/?search=user-invalid
That's for things like if you have a number input and a value is outside of the range. HTML and CSS don't know that the email is invalid. You can use an input with type
email
and use :valid
for essentially matching *@*
, but that doesn't care about if the email is already in useI swear I've seen a way to connect it though to the JS so if the regex matches the :user-valid styles apply and if regex doesn't match :user-invalid styles apply.