Results 1 to 1 of 1

How do I get "booking is in progress" status in PHP?

This is a discussion on How do I get "booking is in progress" status in PHP? within the Programming forums, part of the Web Designing & Development category; My question is on the lines of - unable to pass form data with parameters, in layman words, under booking ...

  1. #1
    Member
    Join Date
    Feb 2018
    Location
    Hyderabad, India
    Posts
    78

    Default How do I get "booking is in progress" status in PHP?

    My question is on the lines of - unable to pass form data with parameters, in layman words, under booking should be appear in the disired place but it is not calling there.

    I am able to pass the file over to PHP using the ajax method. But I need to be able to change the file name to the booking number. For some reason, the booking was not being passed over to the PHP script. So I attempted the following:

    PHP Code:

    $('#uploadBtn').on('click', function()
    {
      var 
    form_data = new FormData();
      
    form_data.append("file"document.getElementById('pdfFile').files[0]);
      var 
    booking = $('#bookingNum').val();
      var 
    partner = $('#partnerCode').val();

      $.
    post('process/fileUpload.php', {booking:bookingpartner:partner}, function(data)
      {
        
    // Wasn't sure if I needed anything here
        
    console.log(data);
      });

      $.
    ajax({
        
    url'process/fileUpload.php',
        
    method:"POST",
        
    dataform_data,
        
    contentTypefalse,
        
    cachefalse,
        
    processDatafalse,
        
    success: function(data){console.log(data);},
        
    error: function(jqHHRtextStatuserrorThrown){console.log('fail: ' errorThrown);}     
      });
    }); 
    As you will notice above, I had to use the $.post method to send the booking and partner over to the php script.

    I then used $.ajax to send the form_data over to the same script.

    (I could not achieve this in one motion from yesterday's question I asked. So this is my second attempt to complete this. If there is a way to send all of the info in one motion, please refer to the question I linked above.)

    So over in the PHP script, I am able to get all of the items I needed with a couple of functions:

    PHP Code:

    <?php
      
    // from the $.post method
      
    if(isset($_POST['booking']))
      {
        
    $booking $_POST['booking'];
        
    $partner $_POST['partner'];
        
    getInfo($booking);
      }
      
    // from the $.ajax method
      
    if($_FILES['file'])
      {
        
    $file var_dump($_FILES['file']);
        
    getFile($file);
      }

      function 
    getInfo($booking)
      {
        return 
    $booking;
      }

      function 
    getFile($file)
      {
        return 
    $file;
      }
    ?>
    I know it's not pretty, but I am able to get the booking (I don't need the partner right now), and I am also able to get the file information.

    What I need to do is rename the file to the booking, and then finally upload it to the necessary directory.

    I wasn't sure if I had to combine the functions, but I did try to no avail.

    With that said, I am able to get the booking and file info within the PHP script. Now how would I go about renaming the file to the booking?
    Last edited by saiwebtech; 06-22-2018 at 07:13 PM. Reason: Typo