| | |
***** User Login problem *****
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hello friends,
I've a user login system......user's name & password are saved in the database.......suppose i've an user "admin". At the time of login if he enters "admin" he can login also if enters "ADMIN" or "AdMiN" he can login too.....how can I stop this thing........PLZZZZZZZ show me the way......
thank you...
I've a user login system......user's name & password are saved in the database.......suppose i've an user "admin". At the time of login if he enters "admin" he can login also if enters "ADMIN" or "AdMiN" he can login too.....how can I stop this thing........PLZZZZZZZ show me the way......
thank you...
For that you could just convert both values to lower case with strtolower(); So try the following and I have included the form.
PHP Syntax (Toggle Plain Text)
<? //mysql connections $username='Admin'; //from mysql in your script $username=strtolower($username); if (isset($_POST['username'])) { $_POST['username']=strtolower($_POST['username']); if ($_POST['username']==$username) { //login } } ?> <form method='post'> <input type='text' value='adMiN' name='username'> <input type='submit' value='submit'> </form>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
If you want it case sensitive then because php is case sensitive, just get php to check if the 2 values = each other. So use the following:
php Syntax (Toggle Plain Text)
<? //mysql connections $username='Admin'; //from mysql in your script if (isset($_POST['username']) && $_POST['username']==$username) { //login echo "test"; } ?> <form method='post'> <input type='text' value='adMiN' name='username'> <input type='submit' value='submit'> </form>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
•
•
according to your solution if I have 1,00,00,000 user will I define those user in that number of veriables ?????????? is this thing feasible ?????????
Below is login.php
php Syntax (Toggle Plain Text)
session_start(); //mysql connect code $result=mysql_query("SELECT * FROM `users` WHERE `username`='".$_POST['username']."' AND `password`='".$_POST['password']."'"); if (isset($_POST['username']) && mysql_num_rows($result)==1) { $row=mysql_fetch_array($result); $_SESSION['username111']==$row['username']; unset($row); header('Location: index.php?login=true'); //there should be no browser output before this line. } ?> <form method='post'> <input type='text' value='Admin' name='username'><br> <input type='text' value='password' name='password'> <input type='submit' value='submit'> </form>
index.php (at top)
php Syntax (Toggle Plain Text)
<? session_start(); if ($_GET['login']=='true' && !isset($_SESSION['username111'])) { echo "<h1>You need to be logged in to view this page!</h1>"; exit; } //no browser output before this line.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Apr 2008
Posts: 293
Reputation:
Solved Threads: 11
here you can use md5 encrypted password....
login.php
when use register or save data in mysql / databse
you have to insert data like...
i think this solves your problem.......
PHP Syntax (Toggle Plain Text)
when you use md5 you got this value in database admin= 21232f297a57a5a743894a0e4a801fc3 ADMIN= 73acd9a5972130b75066c82595a1fae3 AdMiN= 2714cba6c6d58e587565cf4e6b275078
login.php
PHP Syntax (Toggle Plain Text)
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else { // echo('Connected with Mysql'); } @mysql_select_db("db_login", $con); if (isset($_POST['Submit'])) { $user_uname=$_POST["user_uname"]; $user_pass=md5($_POST["user_pass"]); $sql=mysql_query("SELECT * FROM table WHERE user_uname='$user_uname' AND user_pass='$user_pass'"); if (mysql_num_rows($sql)==0 || mysql_num_rows($sql)>1) { echo "<script>alert('Username/password pair is invalid.Please try again.')</script>"; echo"<script language='javascript'>window.location.href='login.php'</script>"; } while($row = mysql_fetch_array($sql)) { if($user_pass==$row['user_pass'] and $user_uname==$row['user_uname']) { //here use go to your new page echo"<script language='javascript'>window.location.href='newprofile.php'</script>"; } else { echo"<script language='javascript'>window.location.href='login.php'</script>"; } } } echo"<script language='javascript'>window.location.href='login.php'</script>"; } }
when use register or save data in mysql / databse
you have to insert data like...
$sql="INSERT INTO table ( user_uname, user_pass) VALUES('$_POST[user_uname]','md5($_POST[user_pass])')"; i think this solves your problem.......
Last edited by Aamit; Dec 2nd, 2008 at 6:11 am.
•
•
Join Date: May 2006
Posts: 18
Reputation:
Solved Threads: 0
[QUOTE=Aamit;748686]here you can use md5 encrypted password....
This is very important, so good on Aamit for pointing this out... not sure if people have taken it onboard as there are no responses!
For security reasons you don't want to make the raw password available in your database, in-case a hacker gets in. An MD5 hash is a good method to ensure you can still verify the users identity without risking a security problem.
PHP Syntax (Toggle Plain Text)
when you use md5 you got this value in database admin= 21232f297a57a5a743894a0e4a801fc3 ADMIN= 73acd9a5972130b75066c82595a1fae3 AdMiN= 2714cba6c6d58e587565cf4e6b275078
This is very important, so good on Aamit for pointing this out... not sure if people have taken it onboard as there are no responses!
For security reasons you don't want to make the raw password available in your database, in-case a hacker gets in. An MD5 hash is a good method to ensure you can still verify the users identity without risking a security problem.
James
BeachyUK.com
BePing - Free Windows Ping Utility
Web Hosting from £5 per year (~$4pa) - Special Offer while we test our payment systems
![]() |
Similar Threads
- How do you minimize a user login? (Windows NT / 2000 / XP)
- Login Problem (Java)
- Login Problem (IT Professionals' Lounge)
- User login Check (ASP)
- prompted to select user to login, but no users listed (Windows NT / 2000 / XP)
- Windows 2000 login Problem (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: About language translotor??
- Next Thread: Please Help with parse error: syntax error
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






