need sm help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
a3venom
Forum Newbie
Posts: 3
Joined: Fri Jun 20, 2008 11:52 pm

need sm help

Post 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";
}
 
 
?>
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: need sm help

Post by vargadanis »

I would not use obdc as it is somewhat slower than using msql functions.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: need sm help

Post 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
}
a3venom
Forum Newbie
Posts: 3
Joined: Fri Jun 20, 2008 11:52 pm

Re: need sm help

Post by a3venom »

thnks @ up
work done :)

:drunk: :drunk:
Post Reply