0

Okay so I need to parse two parts. Here is the code im trying to parse.

<input type="hidden" name="10528935" value="12-1-D33D19A3F048E845A9AA885220729B98" />

I would like it to parse and output like this once done.

10528935=12-1-D33D19A3F048E845A9AA885220729B98

Here is the site I'm trying to do this for

https://www.payqwiq.com/login?uid=582063bd-1973-42e4-8235-b28f5addf8bf

All I need is that data to be parsed and joined like above so I can continue with my program :)

Would appreciate some help if possible :)

I'm completely new in PHP.

Dzje
  • 65
  • 9

1 Answers1

0

Php is a back-end language. Since you are attempting to get data stored in a document object on the front-end, you should use a front-end language to parse the document object, then send the data to a php handler to do what you want with it on the back-end.

Using jQuery you can achieve the desired output with one line of code, then build an ajax call to send the output data to the desired php handler.

// when document is loaded
$(document).ready(function() {
  // get data from document object to send to php handler
  var combinedData = $('input').attr('name') + '=' + $('input').val();

  // execute ajax method to send data to php handler
  sendData(combinedData);

});

function sendData(data) {
  // ajax method to send data to php handler
  $.ajax({
    url: 'pageToSendTo.php',

    type: 'POST',

    data: {
      "data": JSON.stringify(data)
    },

    dataType: 'JSON',


    success: function(data) {
      console.log(data);
    },
    error: function(xhr) {
      console.log('error: ' + xhr.responseText);
    }
  });
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="hidden" name="10528935" value="12-1-D33D19A3F048E845A9AA885220729B98" />

<!-- this is the "pageToSendTo.php" php handler. -->
<?php
if ($_POST['data']) {
    //echo 'received data!';
    $data = json_decode($_POST['data']);
    // do stuff with data
    print_r(json_encode($data));
    
}
?>
Inkdot
  • 266
  • 1
  • 6