devil_vin
09-12-2007, 05:16 PM
Is there any bugs in the following script?My script always execute on else part.Thanks...
<?php
include ('dbconn.cfg');// database configuration file
$connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
if (isset($_SESSION['gmemberid']))
{
$tbl_name = "member";
$sql = "SELECT password FROM $tbl_name";
$result = @mysql_query($sql, $connection) or die("Cannot execute query.");
if (isset($_POST['changePw']))
{
if ($result == $_POST['oldPw'])
{
$update = mysql_query("
UPDATE
$tbl_name
SET
password = '" . mysql_real_escape_string($_POST['newPw1']) . "',
WHERE
password = '" . mysql_real_escape_string($_REQUEST['password']) . "',
");
echo($update);
exit();
$changed = mysql_query($update) or die(mysql_error());
//$result = $_POST['newPw1'];
$redirectUrl = "http://localhost/www2/home.html";
print "<script type=\"text/javascript\">";
print "window.location.href = '$redirectUrl'";
print "</script>";
}
else
{
$status = "Wrong Old Password!";// wrong old password
}
}
}
?>
<?php
include ('dbconn.cfg');// database configuration file
$connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
if (isset($_SESSION['gmemberid']))
{
$tbl_name = "member";
$sql = "SELECT password FROM $tbl_name";
$result = @mysql_query($sql, $connection) or die("Cannot execute query.");
if (isset($_POST['changePw']))
{
if ($result == $_POST['oldPw'])
{
$update = mysql_query("
UPDATE
$tbl_name
SET
password = '" . mysql_real_escape_string($_POST['newPw1']) . "',
WHERE
password = '" . mysql_real_escape_string($_REQUEST['password']) . "',
");
echo($update);
exit();
$changed = mysql_query($update) or die(mysql_error());
//$result = $_POST['newPw1'];
$redirectUrl = "http://localhost/www2/home.html";
print "<script type=\"text/javascript\">";
print "window.location.href = '$redirectUrl'";
print "</script>";
}
else
{
$status = "Wrong Old Password!";// wrong old password
}
}
}
?>