status update error (null field)

Posted by ejah85 on Stack Overflow See other posts from Stack Overflow or by ejah85
Published on 2010-03-21T19:53:29Z Indexed on 2010/03/21 20:01 UTC
Read the original article Hit count: 247

Filed under:
|

hai guys... i .ve the problem that i cannot be recovered yet... i have one form where admin need to approve or reject the booking request... i've set the b_status field in table usage IN PROCESS default value... i want to update the b_status value BOOKING APPROVED when user click APPROVE button.. otherwise, the b_status will update the value as BOOKING REJECTED when user click on the REJECT button

here's is the form code:

<?php
     $db = mysql_connect('localhost','root') 
     or die ("unable to connect");
    mysql_select_db('fyp',$db) or die ("able to select");

    $sql="SELECT * FROM vehicle WHERE v_status='READY'";

     $result = mysql_query($sql) or die ("Query failed!");  
 ?>
 <tr><td>&nbsp;</td></tr>
  <tr>
  <tr>
    <td width="200"><font face="Arial" size="2" font color="#000000">Registration Number </font></td>
    <td><select name="regno">
            <option value="" selected>--Registration No--</option>
            <?php while($row = mysql_fetch_array($result)){?>
            <option value="<?php echo $row['regno']; ?>"><?php echo $row['regno']; ?></option>
            <?php } ?>
        </select></td>
    <td><font face="Arial" size="2" font color="#000000">Reason</font></td>
  <td><textarea name="reason" rows="3" cols="50 "value = ""></textarea></td>
  </tr>
  <?php
     $db = mysql_connect('localhost','root') 
     or die ("unable to connect");
    mysql_select_db('fyp',$db) or die ("able to select");

    $sql="SELECT * FROM driver WHERE d_status='READY'";

     $result = mysql_query($sql) or die ("Query failed!");  
 ?>
  <tr>
    <td><font face="Arial" size="2" font color="#000000">Driver</font></td>
    <td><select id = "d_name" name="d_name">
      <option value="" selected>--Driver Name--</option>
      <?php while($row = mysql_fetch_array($result)){?>
      <option value="<?php echo $row['d_name']; ?>"><?php echo $row['d_name']; ?></option>
      <?php } ?>
    </select></td>
  </tr>
  <tr>
<?php                    
      mysql_close($db);
?>

</table>
<p></p>

<center><input name="APPROVED" type="submit" id="APPROVED" value="APPROVED"> 
<input name="REJECT" type="submit" id="REJECT" value="REJECT"> </center>

      </div>
    </center>

and this is the process page code:

<?php
     $db = mysql_connect('localhost','root') 
     or die ("unable to connect");
     mysql_select_db('fyp',$db)
     or die ("able to select");

    $bookingno=mysql_real_escape_string($_POST['bookingno']);
    $username=mysql_real_escape_string($_POST['username']);
    $name=mysql_real_escape_string($_POST['name']);
    $department=mysql_real_escape_string($_POST['department']);
    $g_date=mysql_real_escape_string($_POST['g_date']);
    $g_time=mysql_real_escape_string($_POST['g_time']);
    $r_date=mysql_real_escape_string($_POST['r_date']);
    $r_time=mysql_real_escape_string($_POST['r_time']);
    $destination=mysql_real_escape_string($_POST['destination']);
    $pass_num=mysql_real_escape_string($_POST['pass_num']);
    $trip_purpose=mysql_real_escape_string($_POST['trip_purpose']);
    $regno=mysql_real_escape_string($_POST['regno']);
    $d_name=mysql_real_escape_string($_POST['d_name']);
    $reason=mysql_real_escape_string($_POST['reason']);
    $b_status=mysql_real_escape_string($_POST['b_status']);


$sql = "INSERT INTO `usage` VALUES('$bookingno','$username','$name','$department','$g_date','$g_time','$r_date','$r_time','$destination', '$pass_num','$trip_purpose','$regno','$d_name','$reason','$b_status')";

                $query = "INSERT INTO `usage` VALUES b_status ='BOOKING APPROVED'";
                $result = @mysql_query($query);

                $query1 = "UPDATE driver SET d_status ='OUT' WHERE '$d_name'=d_name";
                $result1 = @mysql_query($query1);

if(isset($_POST['APPROVED']))
        {

            $query2 = "UPDATE `usage` SET b_status ='BOOKING APPROVED' WHERE '$b_status'='IN PROCESS'";
                $result2 = @mysql_query($query2);

        }


if (isset($_POST['REJECT']))
        {

            $query3 = "UPDATE `usage` SET b_status ='BOOKING REJECTED' WHERE '$b_status'='IN PROCESS'";
                $result3 = @mysql_query($query3);

        }



//$result = mysql_query($sql) or die ("error!");
$result = mysql_query($sql) or trigger_error (mysql_error().' in '.$sql); 

i.ve the problem on the b_status field.. plz guys... help me ya :-)

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql