logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-08-2007, 05:07 PM   #1
amanke
 
Join Date: Sep 2007
Posts: 9
Default login password case sensitive ?

David,
Your video tutorials are EXCELLENT.

I would like the password to be case sensitive like traditional passwords. I saw something about Collate but I tried adding it to the login page but it didn't work. I have viewed all of your tutorials and I would love more.

Thanks
Art
amanke is offline   Reply With Quote
Old 09-08-2007, 09:42 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

use this...

PHP Code:
$no1 "Test"//<< this would be taken from the database 
$no2 "Test"//<< this would be from the form field
 
// here we are using a string compare function which is case sensitive and 
//you are comparing the 2 vars in the function. If they match then the 
//function will run any code in the braces.
 
if(!(strcmp($no1$no2))){ 
 
// do stuff here if it matches + case
 

or you could use an equality test

PHP Code:
if($no1 == $no2){
 
// run code here if true
 

__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-08-2007, 11:49 PM   #3
amanke
 
Join Date: Sep 2007
Posts: 9
Default still a problem

David,
I tried your 2 suggestions but I am very new and I did something wrong because they didn't work. Your help is greatly appreciated.
Here is my code (really your code):

<?php
require_once("connection.php");
//The above was connection.php
session_start ();
$userid = $_POST['userid'];
$upassword= $_POST['upassword'];
$submitted = $_POST['submitted'];
////////////////////////////////////
if ($userid && $upassword ){
$query = sprintf("Select * From users where user_name = '$userid' and user_password ='$upassword'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////
}
if ($rowAccount){
$_SESSION ['id'] = $rowAccount ['user_id'];
header ("location: welcome.php");
exit;
}elseif($submitted){
echo "Sorry but we can't find you in our database";
}
?>

Thanks
amanke is offline   Reply With Quote
Old 09-08-2007, 11:52 PM   #4
owner
 
Join Date: Sep 2007
Posts: 64
Default

What error code do you get when you run the script?

Also, try to use the CODE tags next time please

Last edited by owner; 09-08-2007 at 11:55 PM..
owner is offline   Reply With Quote
Old 09-09-2007, 12:04 AM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

owner

i hand you the baton on this one
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-09-2007, 12:12 AM   #6
owner
 
Join Date: Sep 2007
Posts: 64
Default

Quote:
Originally Posted by davidj View Post
owner

i hand you the baton on this one
Lol, I feel useful
owner is offline   Reply With Quote
Old 09-09-2007, 02:06 AM   #7
amanke
 
Join Date: Sep 2007
Posts: 9
Default

Sorry Gentlemen,
I posted David's code that works but I tried to implement his suggested code for case sensitive passwords and below was my failed attempt. I am very new at php code so thanks for any help.

<?php
require_once("connection.php");
//The above was connection.php
session_start ();
$userid = $_POST['userid'];
$upassword= $_POST['upassword'];
$submitted = $_POST['submitted'];
////////////////////////////////////
if ($userid && $upassword ){
$query = sprintf("Select * From users where user_name = '$userid' and user_password ='$upassword'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////
}
if ($rowAccount){
$no1 = $rowAccount ['$user_password'];
$no2 = $upassword;
if($no1 == $no2){
$_SESSION ['id'] = $rowAccount ['user_id'];
header ("location: welcome.php");
exit;
}}elseif($submitted){
echo "Sorry but we can't find you in our database";
}
?>
amanke is offline   Reply With Quote
Old 09-09-2007, 02:15 AM   #8
owner
 
Join Date: Sep 2007
Posts: 64
Default

Quote:
Originally Posted by amanke View Post
Sorry Gentlemen,
I posted David's code that works but I tried to implement his suggested code for case sensitive passwords and below was my failed attempt. I am very new at php code so thanks for any help.

<?php
require_once("connection.php");
//The above was connection.php
session_start ();
$userid = $_POST['userid'];
$upassword= $_POST['upassword'];
$submitted = $_POST['submitted'];
////////////////////////////////////
if ($userid && $upassword ){
$query = sprintf("Select * From users where user_name = '$userid' and user_password ='$upassword'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////
}
if ($rowAccount){
$no1 = $rowAccount ['$user_password'];
$no2 = $upassword;
if($no1 == $no2){
$_SESSION ['id'] = $rowAccount ['user_id'];
header ("location: welcome.php");
exit;
}}elseif($submitted){
echo "Sorry but we can't find you in our database";
}
?>
Again, please use the CODE tags, but here is your problem.

PHP Code:
 if ($rowAccount){
 
$no1 $rowAccount ['$user_password'];
 
$no2 $upassword;
 if(
$no1 == $no2){
$_SESSION ['id'] = $rowAccount ['user_id'];
header ("location: welcome.php");
exit;
}}elseif(
$submitted){
echo 
"Sorry but we can't find you in our database";

This is what it should be.

PHP Code:
if($no1 == $no2){
$_SESSION ['id'] = $rowAccount ['user_id'];
header ("location: welcome.php");
exit;
}elseif(
$submitted){
echo 
"Sorry but we can't find you in our database";

I may be wrong as I am new to this, so post a reply back if it doesn't, but what you did wrong was you had the {} mixed up and you didn't have to use both of David's codes, just one or the other.

Give that ago, try to learn what you did wrong by comparing both sources and see what happens.

Feel free to post back
-Owner

Last edited by owner; 09-09-2007 at 02:18 AM..
owner is offline   Reply With Quote
Old 09-09-2007, 03:23 AM   #9
amanke
 
Join Date: Sep 2007
Posts: 9
Default

I followed all of David's video tutorials and entered the code and tested and everything worked until he added "sessions". When I pressed F12 things wouldn't run on my local server but when I uploaded to my website they worked. So all of his code worked on my website but not on my xp local server. When I tried to add the code for case sensitive password the page will not load. I tried your suggestion and it didn't help. You mentioned error tags and I don't know how to give these to you. When I go to my website with Firefox I get this message:

The page isn't redirecting properly


Firefox has detected that the server is redirecting the request for this address in a way that will never complete.


* This problem can sometimes be caused by disabling or refusing to accept
cookies.
amanke is offline   Reply With Quote
Old 09-09-2007, 03:34 AM   #10
owner
 
Join Date: Sep 2007
Posts: 64
Default

It sounds like the security that you have on firefox is maxed and isn't allowing session cookies. Try lowering your security for a second, test the page, then if it works, you know it is your security level. If not, then put your security back up.

Note: if your security levels turn out to be high, slowly adjust your security level back up till it keeps working so that you still browse securely.
owner is offline   Reply With Quote
Reply


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


All times are GMT. The time now is 07:52 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com