PDA

View Full Version : login.php help


RawliJr
05-21-2006, 06:13 PM
This is my login.php

<html>
<body>
<?php
if (isset($_COOKIE["uname"]))
echo "Welcome " . $_COOKIE["uname"] . "!<br />";
else
echo "You are not logged in!<br />";
?>
</body>
</html>

What im trying to do is if i have the right password and right username it lets me in, but if one or another is wrong i want it to say something like Invalid username or password.And i dont know what i would put for the code so can i have some help please

And do i need to set up a database or any mysql tables?:mad:


Thanks,
Rawli

trib4lmaniac
05-21-2006, 06:42 PM
Only requiring the username in a cookie is a very bad idea. I could easily create a cookie on my machine with your username without even knowing your password!

I'm afraid I don't have the time to write you an entire login script right now though, just my 2p.

RawliJr
05-21-2006, 06:44 PM
how would i make the script then?

RawliJr
05-21-2006, 06:46 PM
would i use the if..else state ment?

RawliJr
05-21-2006, 08:48 PM
This is what i would like if i have the right pass and username , it logs me on but if i have the wrong pass or w.e its doesnt let me in?


how would i code this? and what will i need like mysql php and?

anarchy3200
05-21-2006, 09:36 PM
If you are jsut checking for a single authentication and are happy to hard code it you will not need any sql database, just:

<?PHP
if($_POST['username'] == 'username' AND $_POST['password'] == 'password'){
print "You have logged in";
print "All the logged in content should go here.";
}else{
print "Your username or password was invalid";
}
?>

Your form would submit to the page with this in and the textbox fields should be called username and password. This would provide the basic login that you seem to be looking for, security and functionality are lacking but if this is all you need then this would work fine.