Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 13th, 2007, 10:11 PM   #1
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
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>
kishou is offline   Reply With Quote
Old Dec 13th, 2007, 10:39 PM   #2
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 416
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
Re: login system

Besides PHP??? You mean storing usernames and passwords in a database?
__________________
JG-Webdesign
Wizard1988 is offline   Reply With Quote
Old Dec 13th, 2007, 11:21 PM   #3
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
Re: login system

Quote:
Originally Posted by Wizard1988 View Post
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
kishou is offline   Reply With Quote
Old Dec 14th, 2007, 12:42 AM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,623
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
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.
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Dec 14th, 2007, 12:54 AM   #5
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3 Jimbo is on a distinguished road
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".
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Dec 14th, 2007, 1:50 AM   #6
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
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 is offline   Reply With Quote
Old Dec 14th, 2007, 2:20 AM   #7
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
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>
kishou is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Login System MikeC PHP 17 Dec 17th, 2005 10:11 AM
PHP system commands ktsirig PHP 6 Oct 4th, 2005 1:24 AM
Why shouldn't we use System(); Shapeless C++ 7 Jul 19th, 2005 6:10 AM
how to login computers with same login and password Tiger Java 5 Jan 31st, 2005 7:53 PM
How to write a login system? uman C++ 2 Jan 13th, 2005 1:33 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:06 AM.

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