Jump to content

MySQL Disobeying Commands


maxudaskin

Recommended Posts

I tell it to change a 1 to a 2 but it ignores the command, if I input deny, instead of changing it to 2, it changes it to 0.

 

<?php
if(!$logged_in){
   echo 'You are not logged in';
}else{
   if($_SESSION['type'] == 1){
      $action        = $_GET['action'];
      $pirep         = $_GET['pirep'];
      $admin         = 'OOM'.$_SESSION['username'].' '.$_SESSION['name'];
  $get_user_info = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'");
      $pid           = mysql_fetch_array($get_user_info);
  $usersql       = mysql_query("SELECT * FROM users WHERE pid = '{$pid}'");
  $user_array    = mysql_fetch_array($usersql);
  $user          = $user_array['fname']." ".$user_array['lname'];
  $rank          = $user_array['rank'];
      $date          = date("Y-m-d H:i:s");
  if(!empty($action) || !empty($pirep)){
         if($action == 'accept'){
            mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '0' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error());
            echo 'PIREP Accepted.';
		echo $user_array['email'];
		$to = $user_array['email'];
            $subject = "Flight Report Accepted";
		$pirep_sql    = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'");
        $pirep_info    = mysql_fetch_array($pirep_sql);
            $message = $rank ." ". $user .",
The recent flight report that you have filed has been accepted. Your hours have been updated accordingly.

The report was accepted by ".$pirep_info['acceptedby']." on ".$pirep_info['accepteddatetime'];
            $from = "[email protected]";
            $headers = "From: $from";
            mail($to,$subject,$message,$headers) or die ("<br /><br /><div class=\"status_message status_error\">ERROR: Email not sent to user.</div>");

         }elseif($action == 'deny'){
         mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '2' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error());
	 echo "Pirep Denied.";
      }else{
         echo 'You have specified an unknown action.';
      }}
   }else{
      echo 'You are not a staff member.';
   }
}
  ?>

 

Inputs: action=deny&pirep=141

 

upl8865434991.jpg

Link to comment
https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/
Share on other sites

Try this.  It is untested, so it might have some errors or something...  You might also have to change the strings within the brackets to just a regular string..  but since this isnt the full code, that might not be the case.

 

At any rate, try it and let me know what happens.

 

<?php

if (!$logged_in) {
echo 'you are not logged in';
} else {
if ($_SESSION['type'] == 1) {
$_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$_pirep = isset($_REQUEST['action']) ? $_REQUEST['pirep'] : '';

      $admin         = 'OOM'.$_SESSION['username'].' '.$_SESSION['name'];
  $get_user_info = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'");
      $pid           = mysql_fetch_array($get_user_info);
  $usersql       = mysql_query("SELECT * FROM users WHERE pid = '{$pid}'");
  $user_array    = mysql_fetch_array($usersql);
  $user          = $user_array['fname']." ".$user_array['lname'];
  $rank          = $user_array['rank'];
      $date          = date("Y-m-d H:i:s");
switch ($_action) {
case accept:
mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '0' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error());
            echo 'PIREP Accepted.';
		echo $user_array['email'];
		$to = $user_array['email'];
            $subject = "Flight Report Accepted";
		$pirep_sql    = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'");
        $pirep_info    = mysql_fetch_array($pirep_sql);
            $message = $rank ." ". $user .",
The recent flight report that you have filed has been accepted. Your hours have been updated accordingly.

The report was accepted by ".$pirep_info['acceptedby']." on ".$pirep_info['accepteddatetime'];
            $from = "[email protected]";
            $headers = "From: $from";
            mail($to,$subject,$message,$headers) or die ("<br /><br /><div class=\"status_message status_error\">ERROR: Email not sent to user.</div>");
break;
case deny:
mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '2' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error());
	 echo "Pirep Denied.";
break;

default:
echo 'You have specified an unknown action.';
break;
}
} else {
echo 'You are not a staff member.';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.