The below code most times work success, but if at line:
(!($result && $result1 && $result3)) {
one is FALSE so whole is TRUE so ROLLBACK executes , this [the ROLLBACK] do NOT work, tables updated rather rollback,
and nothing get updated , well ?
I tried both
1. @mysql_query("BEGIN");
2. begin();
...
Code:
<?php
$query2 = "SELECT * FROM $CustomersTable WHERE status='active' AND email='".$_POST['email2']."' AND password='".$_POST['password2']."';";
$result2 = @mysql_query($query2,$linkid);
$count2 = @mysql_num_rows($result2);
mysql_free_result($result2);
if ($count2 > 0) {
function begin()
{
@mysql_query("BEGIN");
}
function commit()
{
@mysql_query("COMMIT");
}
function rollback()
{
@mysql_query("ROLLBACK");
}
@mysql_query("BEGIN");
$query ='';
$query = "UPDATE $CustomersTable SET status='deleted' WHERE status='active' AND email='$email2' AND password='$password2';";
$query1 ="INSERT INTO $CanceledCustomersTable SELECT * FROM $CustomersTable WHERE status='deleted' AND email='$email2' AND password='$password2';";
$query4 = "SELECT * FROM $BookingsTable WHERE email='$email2'";
$result4 = @mysql_query($query4,$linkid);
$count4 = @mysql_num_rows($result4);
if ($count4>0) {
$query3 = "UPDATE $BookingsTable SET status='k' WHERE email='$email2';";
$result3 = @mysql_query($query3,$linkid);
} else {
$result3 = true;
}
$result = @mysql_query($query,$linkid);
$result1 = @mysql_query($query1,$linkid);
if (!($result && $result3)) { // $result1 &&
echo "<p align='center'>Unable to execute Query(wrong UserName/Password),<br /> please go back and retry... redirecting...</p>";
mysql_close($linkid);
sleep(6);
@mysql_query("ROLLBACK"); ?>
<script type="text/javascript">alert("Please check that you've entered CORRECT Password! Redirecting to previous WebPage ... ");setTimeout(location.href="https://www.poliscarhire.com/customeradmin/register-ac-modify.php",5000);</script><?php
exit();
} else {
unset($_SESSION["email"]);
unset($_SESSION["password"]);
@mysql_query("COMMIT");
$subject = "Delete Account Notification";
$message_del_ac = "<p align='center'>Your Account with PolisCarHire.com ( ID= $email2 ) has been Deleted Permanently. </p><p align='center'>This is the last notification sent ! If you like to reopen an Account please <a href='https://www.poliscarhire.com/customeradmin/register-ac.php'>Register Here</a>, thks ! </p>";
$headers = "From:info@poliscarhire.com";
$headers .= "\nReply-To:info@poliscarhire.com";
$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";
$email3 = "$email2,info@poliscarhire.com";
mail($email3,$subject,$message_del_ac,$headers);
mysql_close($linkid);
?>
<p> </p>
<p align="center">Your Account with PolisCarHire.com ( ID= <?= $email2 ?> ) has been Deleted Permanently. </p>
<p align="center">An Email notification sent ! If you like to reopen an Account please <a href="register-ac.php">Register Here</a>, thks ! </p>
<? }
} else {
echo "Please check that you've entered CORRECT Password! Redirecting to previous WebPage ... ";
mysql_close($linkid);
?><script type="text/javascript">alert("Please check that you've entered CORRECT Password! Redirecting to previous WebPage ... ");setTimeout(location.href="https://www.poliscarhire.com/customeradmin/register-ac-modify.php",5000);</script><?php
}
?>