PDA

View Full Version : PHP code?



Newsie
24-02-2006, 09:37 PM
OK. I have used TechTuts user system tutorials to make a user system. But I need a code that will check if the password on that account is changeme. And if it is, redirect them to the password change page. Reputation will be awarded! KKTHNX.

D3stroyer
24-02-2006, 09:39 PM
Hey i don't think you really need that script, because if the person has anybrains what so ever he/she will change there password anyway.


-Daza

Newsie
24-02-2006, 09:41 PM
No it's a school thing. I'm making the accounts. So when they login I need them to change their password.

D3stroyer
24-02-2006, 09:44 PM
Oh i hate school things they have to be so difficult.


-Daza

Newsie
24-02-2006, 09:49 PM
Tell me about it.

Tomm
24-02-2006, 10:08 PM
Since the password is encrypted its all most impossible.

nets
24-02-2006, 10:35 PM
I'm assuming that the user logs in and the variable of the field where they type the pass is "pass". Just put this as the first thing in your PHP on the page where the user goes when they log-in, and it should work depending on the script etc.


if($_POST['pass'] == 'changeme') {
header('location: http://www.google.com');
die();
}

If it doesn't work post the script here, or link to the site and I'll try and work something out to fit in with your site.

Mentor
25-02-2006, 12:29 AM
How are the posts stored in the database?
i mean is it just text so "changeme" or the md5 hashed "changeme" or possibly a custom algorthum "/

timROGERS
25-02-2006, 08:04 AM
If you need to fish the pass out of a database it will almost certainly be encrypted.

Luckyrare
25-02-2006, 01:39 PM
You could have a table in the mysql called oldpass and newpass

then you could compair them and if they match it would say bleh bleh bleh. You could do that by editing Nets if/else code.

Sygon.
25-02-2006, 02:39 PM
Let me use my unhelpful new knowledge of th if statements


if ($password == changeme) echo 'Sorry your password cannot be changeme' /* then somin here that makjes him redo it lol */

else echo ' thanks '


sorry for my poor underestanding of php

- sy

Splinter
25-02-2006, 03:05 PM
it should be :


if ($password == changeme) {echo 'Sorry your password cannot be changeme'} /* then somin here that makjes him redo it lol */

else {echo ' thanks ' } but that wont really work :P

Sygon.
25-02-2006, 03:08 PM
yep but i was reading a book yesterday so i have forgotten ill read it again and re do it atleast im learning lol


- sy

nets
02-03-2006, 06:45 PM
This is an old post now, but I was just looking back and are you sure that any users actually have their password as "changeme"?
If not, I can write a basic script to check (may need some modification).


<?php
$data = mysql_query("SELECT password FROM users");
$data = mysql_fetch_array($data);
foreach ($data as $password) {
if($password == md5('changeme')) {
$count_changes++;
}
}
if(!$count_changes) {
print 'No users need their passwords changed';
} elseif($count_changes=='1') {
print '1 user needs their password changed';
} else {
print $count_changes.' users needs their password changed';
}
?>

P.s. I've written that in this window without checking it, so there's probably some errors.

nets
02-03-2006, 06:46 PM
Damn lag.

Want to hide these adverts? Register an account for free!