/    Sign up×
Community /Pin to ProfileBookmark

Alright, so i am using JPMaster’s Login Script and i am trying to find a way to “deceive” the script by asking the code to see if the “false” form is the same as the real Password. In other words as the administrator, if someone has forgotten their password, i can give them their password. The problem is that when they submit their registration, i can see their password, but it is encrypted. This code would validate to see if the text in the confirm password box was the same as the password box (but this wouldn’t mean anything, just would give me the administrator the ability to see what their password is.

This is the part in question:

[code]
/* Password error checking */
$field = “pass”; //Use field name for password
if(!$subpass){
$form->setError($field, “* Password not entered”);
}
else{
/* Spruce up password and check length*/
$subpass = stripslashes($subpass);
if(strlen($subpass) < 4){
$form->setError($field, “* Password too short”);
}
/* Check if password is not alphanumeric */
else if(!eregi(“^([0-9a-z])+$”, ($subpass = trim($subpass)))){
$form->setError($field, “* Password not alphanumeric”);
}
/**
* Note: I trimmed the password only after I checked the length
* because if you fill the password field up with spaces
* it looks like a lot more characters than 4, so it looks
* kind of stupid to report “password too short”.
*/
}

/* Confirm Password error checking */
$field = “confirm”; //Use field name for confirm
if(!$subconfirm || strlen($subconfirm = trim($subemail)) == 0){
$form->setError($field, “* Confirmed Password not Entered”);
}
else{
/*Check if valid Confirmation number */
$subconfirm = stripslashes($subconfirm);
// This is an example, you can change this
if(!eregi(“^([0-9])+$”, $subconfirm)){
$form->setError($field, “* Confirmed Password contains non-numerals
[/code]

Any suggestions. Otherwise, the alternative would be to somehow acquire the capabilities to change their password, but that would take alot more coding.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Mr__E__CrypticJul 27.2008 — the alternative would be to somehow acquire the capabilities to change their password, but that would take alot more coding.[/QUOTE]

but, it's the way you should do it. passwords should always be encrypted in some fashion or other.
Copy linkTweet thisAlerts:
@youngdesignerauthorJul 27.2008 — so how would i change it to give me the ability to change the password?
Copy linkTweet thisAlerts:
@NogDogJul 27.2008 — Most password systems that use hashed passwords (note that "hashed" != "encrypted", as "hashed" passwords are intentionally not supposed to be decrypted) handle forgotten passwords by generating a new, random password, emailing it to the user, and setting a flag in the user table that will require the user to change it when they log in with that new password.

If you want to be able to decrypt it, then you need to use encryption instead of hashing. If implemented on the PHP side, this would typically mean using the [url=http://www.php.net/mcrypt]mcrypt extension[/url]. Alternatively (and what I usually do) you can use the DBMS's own encryption/decryption functions, such as AES_ENCRYPT() in MySQL.
Copy linkTweet thisAlerts:
@youngdesignerauthorJul 27.2008 — So how would i be able to do this with the code above? Or are you familiar with JP's Script? Where/how would i change it?
Copy linkTweet thisAlerts:
@youngdesignerauthorJul 27.2008 — Okay, i think i thought of a better question to ask, kinda concerning the same thing. I have been asking how to change a members password without knowing their password (so this new one would act as a temporary password. Is there a way to have a form where it would ask for the username that you wish to change the password to. Then you would type the new password. When you hit submit, the form would replace the current password with the new one (this new code would be md5 protected). Is there a way to ensure that the first part states which user you want to edit, then the next field would only change the password so that it is also md5 okayed. Is this possible?
×

Success!

Help @youngdesigner spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...