Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Web Development Languages (http://www.programmingforums.org/forum40.html)
-   -   login system (http://www.programmingforums.org/showthread.php?t=14755)

kishou Dec 13th, 2007 11:11 PM

login system
 
ok im making a simple login. And im wondering how to make one besides using php. here's the code:
HTML file:
:

<html>
<head>
<title>
</title>
</head>
<body>
<form action="login.php" method="post">
Username: <input type="username" name="username" /><br/>
Password: <input type="password" name="password" /><br/>
<input type="submit" value="Login" />
</form>
</body>
</html>

PHP code:
:

<html>
<body>
<?php
if ($_POST["username"]&&$_POST["password"]=="admin")
echo "Login Successful";
else
echo "Username and password are incorrect. Please try again";
?>
</body>
</html>


Wizard1988 Dec 13th, 2007 11:39 PM

Re: login system
 
Besides PHP??? You mean storing usernames and passwords in a database?

kishou Dec 14th, 2007 12:21 AM

Re: login system
 
Quote:

Originally Posted by Wizard1988 (Post 138408)
Besides PHP??? You mean storing usernames and passwords in a database?

yea besides php. someone told me that you can do that in javascript but im not sure. and no not storing it has to be username:admin and password: admin

big_k105 Dec 14th, 2007 1:42 AM

Re: login system
 
if you are doing this in javascript then anyone can see what the username and password is suppose to be. And then there really isn't any point to the login.

Jimbo Dec 14th, 2007 1:54 AM

Re: login system
 
The problem with a JavaScript login system is that anyone can see the JavaScript. They can also turn it off. They can also overwrite it to return whatever they want. That's the problem with trusting the client - you can't.

Using PHP on the other hand, the user has to input values and those are validated on the server - which the user [hopefully] has no control over. This is why PHP logins are more secure. With PHP (or another server-side language), you can also use a database to store login information, so it's a ton more scalable as well.

That said, your PHP code is incorrect. You need to make the comparison for both strings, not just one. The if statement will probably work with any username so long as the password is "admin".

kishou Dec 14th, 2007 2:50 AM

Re: login system
 
well the thing is its suppose to be for the psp and its not going to be hosted or anything its just a simple login. so it wont matter who can see the username or password because the person wont be connected to the internet. and the reason im not doing PHP is because PHP isnt installed on the PSP. And thanks for the mistake i didnt see that before. ;) also then what should i put instead of if?

kishou Dec 14th, 2007 3:20 AM

Re: login system
 
ok corrected the php file to this. and it works:
:

<html>
<body>

<?php

if ($_POST["username"]=="admin"&&$_POST["password"]=="admin")
echo "Login Successful";
else
echo "Username and password are incorrect. Please try again";
?>
</body>
</html>



All times are GMT -5. The time now is 4:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC