![]() |
made a login for admin (need help)
hello, as i am learning php i just work out of my ass sort of speek
so this is one try so please dont flame me or so on, and try to be as clear about the things you explain to me thank you. PHP Code:
The Question is, what have i done wrong? and what should i fix. ps, NO FLAME! please. ty Quote:
|
Hi codefreek. What, if any, error message are you receiving?
One thing I notice right away is that your form's HTML is within the <?php ?> tag. This will fix that: PHP Code:
One thing to remember and this is important, when doing comparisons in PHP, you need to make sure and use either the '==' or the '===' operators as just using a '=' will just set the variable. This will in turn always result in a true stement. example: PHP Code:
PHP Code:
Also, you are a little paranoid about being flamed. Has someone here done that? |
Your input is named "usernamn". So $_POST['username'] will always be blank.
|
If, for some reason, you wanted the form within the php tags (<?php ?>), you will need to "escape" the double quotes (") with a backslash (\).
For example Code:
Username: <input name=\"usernamn\" type=\"text\" value=\"\" /> |
Or perhaps a slightly faster method would be to do:
PHP Code:
|
I tried to make the best out of it, and here's how I solved it:
PHP Code:
NOTE: I wrapped this up in really no time at all, so security is none whatsoever. You might want to secure the $_POST variables.. and other aspects. |
as this is only for testing i will only secure it later when i will use it later on.
BUT THANK YOU TANAX :D |
I'm pretty sure it's a bad idea to SELECT * when just verifying a username and a password. I would just SELECT the fields you need that way there is no way someone could gain access to a password.
PHP Code:
|
Quote:
PHP Code:
|
| All times are GMT. The time now is 02:15 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0