Professionals handle this problem by carefully screening all input, enforcing strong password standards (so that users can't guess other users' passwords), and by storing the credentials in the code on the page but rather by using a randomly generated session token to map the user's token to identity on the server.
Client's can easily send any data they want by circumventing all of your client code. You have to assume the client is evil and look at protecting your server from that perspective.
EDIT:
If you need some help with tokens and their usage, this question might help you: PHP cookies and member security
If you are new to security I would highly recommend the Web Application Hacker's Handbook. I have read it and it is very thorough and interesting to read.
There is also a new book out called the Web Application Defender's Cookbook that looks quite promising, though I haven't read it.