John Crawford John Crawford - 3 months ago 8
MySQL Question

Any way to see php POST data from external sources?

OK...so here's the deal. I've been experimenting with RFID technology. Long story short, the RFID reader can send data read from tags to an HTML page as a data stream. Therefore the data gets sent as POST data. Let's say I have a page called datastream.php that takes the post data and writes the data to a MySQL database and that's it.

Is there any way to create a separate page (data-monitor.php) that will show the POST data that is being sent from the RFID reader to the datastream.php page in real time (or close to it)? Maybe AJAX? Sorry there's no code examples. This is more a high level question to see if will even work. I have a feeling that I'll probably just make the data-monitor.php page update a div or something with data from the MySQL tables as it gets written using AJAX.

Answer

2 ways i guess , the first is to create a php page and use $_POST['input name'] and then echo the values .

Or using Browsers to see The POST data , i do use it when i have an AJAX code and want to know if it did pass a values to the target page . Now how can you do that ?

First this is AJAX code that i use to to submit a from to another php code :

<script>
    function usersignup()
    {
      var username = document.getElementById("username").value;
      var email = document.getElementById("email").value;
      var password = document.getElementById("password").value;
      var r_password = document.getElementById("r_password").value;
      var gender = document.getElementById("gender").value;



      if(r_password != password)
        {
            document.getElementById('notmatchpass').style.display ='block';
        }

        else
        {

      if(username && email && password && gender)
      {
        $.ajax
        ({
          type: 'post',
          url: 'lib/signup.php',
          data: 
          {
             newuser:username,
             user_email:email,
             user_password:password,
             user_gender:gender
          },
          success: function (response) 
          {
            document.getElementById("respond").innerHTML=response+document.getElementById("respond").innerHTML;
            document.getElementById("signupform").innerHTML="";

          }, 
                error: function(response) {
                console.log(response);
            }
        });
      }
      }
      return false;
    }
</script>

This is the part that used to activate the console ( browser console )

error: function(response) {
console.log(response);}

Now just to test if its working or not , before i submit the form , i will do this :

  • Click F12 on the browser
  • Pick from the tool bar ( Network )

enter image description here

  • Now i will submit the form
  • After that i will pick Parmas

enter image description here

  • Now what we are going to see is the data that were sent

enter image description here

For me as i said i did not find anything else to use it except to testing . But other Developers for sure need it .

Comments