Pseudocode: https://pastebin.com/riecfFu4 `
CLIENT CODE:
function Login()
{
form f = {username, password};
WWW request = SendRequest("https:/.../login.php", f);
wait request;
if(request.error != NULL || request.message == "ERROR")
return "Error";
else
{
if(request.message == "LOGIN_OK")
GoForwardAndLoadNextThing();
}
}
SERVER CODE:
function ProcessLogin(form f)
{
Query q = SELECT username WHERE user = f.user AND password = f.password;
QueryResult result;
q.DoQuery(result);
// If there was a match
if(result != 0)
die("LOGIN_OK")
else
die("ERROR");
}
`
Hello! I'm pretty new to web-dev and did only a super simple client-server program many years ago which works pretty much like the pastebin pseudo-code I've sent.
However I figured out that it looks pretty wrong, what if you can just inject "LOGIN_OK" in the request.message and pass your check without it really being valid? It kinda spoils the safety of the client-server architecture?
The protocol I've used to communicate between the client and the server is HTTP/HTTPS, specifically (and I don't know if it is wrong, so please point me out) the client asks for a page on the server (.php) while providing a form, the server responds by writing on the blank page the result (like "LOGIN_OK") which is then read by the client, and in base of what it reads does different kind of stuff, like failing or going forward.
I'm super super new to this, and the only protocol I know is HTTP, how far off I am from this being ok?
If it can help, I'm trying to make a suuuper simple client app that has login/registration where users can write posts, which are fetched by all clients and displayed on the homepage.
Can you point me out in the right direction? Thanks a lot.
I've came up with that kind of architecture to communicate but found it's pretty weak.