Page 1 of 1

need sm help

Posted: Sat Jun 21, 2008 12:00 am
by a3venom
hi guys
i own a mmorpg game server wich uses msql2000 dbs
m just a newbie php programmer n i m creating a change password page fr my MSSQL2000 server
but i cant get my thing 2 be done
this is what i want to do
Image
:banghead: :banghead: :banghead:
Kindly help plss..................
here s my code
but it cannot check the current pass field with the actuall pass
getting no error msgs.. but its unable 2 check

Code: Select all

<?php
$dbname="ASD";
$user="sa";
$pass="sa";
$conn = odbc_connect($dbname, $user,$pass );
$newpass="$_POST[newpass]";
$confirmpass="$_POST[confirmpass]";
$currentpass = "$_POST[currentpass]";
$userid = "$_POST[userid]";
$chckpass = "SELECT c_headera FROM account WHERE c_id ='$userid'";
$realcheck = odbc_exec($conn, $chckpass);
$realpass = odbc_result($realcheck,'c_headera');
echo $realpass;
if ($realpass = $newpass)
ECHO "Current Password Is Wrong";
 
else 
 
switch ($newpass)
{
case $confirmpass:
$query = "update account set c_headera='$_POST[newpass]', c_headerb='$_POST[newpass]', c_headerc='$_POST[newpass]', c_sheadera='$_POST[newpass]', c_sheaderb='$_POST[newpass]', c_sheaderc='$_POST[newpass]' where c_id='$_POST[userid]'";
$result  =  odbc_Exec($conn,  $query);
echo "Password Changed Successfully!";
break;
 
default:
Echo "Passwords Do Not Match";
}
 
 
?>

Re: need sm help

Posted: Sun Jun 22, 2008 5:24 am
by vargadanis
I would not use obdc as it is somewhat slower than using msql functions.

Re: need sm help

Posted: Sun Jun 22, 2008 7:18 am
by Kieran Huggins
instead of retrieving the password from the DB, why not do the comparison in the DB itself?

Code: Select all

$result = msql_query("SELECT c_id FROM account WHERE c_id='$userid' AND c_sheadera='$password';");
if( msql_num_rows($result) > 0 ) {
  // passwords match
}else{
  // passwords don't match
}

Re: need sm help

Posted: Mon Jun 23, 2008 4:54 am
by a3venom
thnks @ up
work done :)

:drunk: :drunk: