Handling of the post request and execute another script in PHP [duplicate] - php

This question already has answers here:
How do I close a connection early?
(20 answers)
Continue PHP execution after sending HTTP response
(13 answers)
Closed 9 years ago.
So I have a PHP script that handles post requests. It works quite good, but (always a but) the data I am receiving is encoded. I need to run an external program to decode it. That also works.
My problem is, that my client connects to the server, does a POST and waits for the OK reply from the server, to verify that the post request has been handled correctly. Now when I add the part of the Decoder into my POST request handling script, it takes some time for my client to receive the OK from the server. It is only sending it back when the entire script has been finished, and not only the uploading of the files part, understandably.
What I was wondering now, can I do this in another way? When the uploading of the files is done, the client should now that the upload is finished. He should not have to worry about the decoding part. I also need it to decode immediately after the POST request has been handled, so I'm a bit puzzled at how I need to do this...
Don't really think I need to give out my code but if the need should arise i'll be glad to oblige.

Related

Replicate request payload with cURL, PHP [duplicate]

This question already has answers here:
RAW POST using cURL in PHP
(2 answers)
Closed 3 years ago.
There is a website that when you fill some form, it send a xhr request with some content of the form in the payload header. The content is similar to this one (not exactly this, this one was extracted from another website, but the same format of content separated with pipes):
7|0|5|https://www.bosscapital.com/app/Basic/|B8CC86B6E3BFEAF758DE5845F8EBEA08|com.optionfair.client.common.services.TradingService|getAssetDailyTicks|J|1|2|3|4|2|5|5|CB|U9mc4GQ|
I want to replicate this request with cURL but I don't know how to do it. I don't know the name of the input fields (because the have no name in the HTML code and I can't find the request on the JS).
I was looking at some Stack Oveflow treads like this, this or this, but still is not clear for me how to do it.
Hope you can help.
P.D.: I know how to use cURL, but I din't even know this Request Payload thing before this job was assigned to me.
I strongly recommend you to use Postman to run your call (or see the curl version)
https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop
with the interceptor to catch the XHR request https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo

How to close an open web socket from java script, html 5

I have a simple chat program than runs on a php web-socket. There is simple php script that runs on server computer which processes incoming data and forwards it to other sockets.
The questions is how can I check if a a websocket is closed from clients end.
I know that when socket.close(); is called on client side, php script receives 2 bytes of data but when I unmask it, it seems to be empty.
Please can anyone shed little light on this. Thank You
UPADTE:
This is weird.
There is certain data when I unmask I get ♥8. why is this ?
UPDATE 2:
Okay,
Further investigation reveals the following
if socket.close(); is called from your browser. Your socket_recv() function will recieve 6 bytes of data and when unmasked it will have null.
If you browser windows is closed which has websocket active your socket_recv() function will get 8 bytes of data and when unmasked will reveal ASCII characters 3 and 233.
I dont exactly know whats hap

How to access the HTML table from PHP [duplicate]

This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 8 years ago.
I have a page with a java script that adds a row to a table. On the same page there is a PHP script that should read the table and add it to the database. How do I read the table using PHP ?
What you're thinking of will not directly work.
A Javascript script is executed on the client side only, whereas a PHP is executed on the server side only, and before the datas are sent to the client.
PHP can not directly read the table.
What you can do is use AJAX to send the data from the user's browser to a PHP script that'll use them.
You'll find more infos here.
PHP is serverside programing, the PHP code serves data to the client - PHP can't read from the client.
If you add a row using javascript, PHP has no way of getting that info.
You'll need to use Ajax to solve your specific problem.
You cannot "read the table" with PHP. You will have to send the data of the table to the server (and read it with PHP) using JavaScript or CGI.
A well-known technique to do this is called Ajax.

Execute PHP code via javascript [duplicate]

This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 9 years ago.
I'm trying to connect to my SQL server via Javascript.
In order to do this, I have to execute some PHP code, but I'm having some trouble with that.
At the moment I use this code to execute a PHP script, without success
function testConnection()
{
$.get("script/SQL/testConnection.php");
}
How is it possible to execute some PHP code, or connect to the server and execute SQL queries?
Thanks
Matt
That $.get call you have is a relative URL. Let's say your user is on page domain.com/home/. If you use that code block, the user's browser is going to make a GET request to domain.com/home/script/SQL/testConnection.php. Is that what you are expecting?
What HTTP status code are you receiving back?

Send iPhone data to PHP file [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
iPhone: Post data to php page
Passing Data From iPhone app to PHP file
What is the best way to send simple numerical and textual data from an iphone app to a php application?
Essentially what I am trying to do is to get the data input by users sent to a php file so it can be stored in a remote database.
What is the best way to send data from an iphone app to a php app so it can be stored in a MYSQL database...
assuming you know which fields are being sent, there is nothing to stop you sending the data via post, but make sure you validate/sanitise on the php side.
if you choose to go this route, I would have a look at http://allseeing-i.com/ASIHTTPRequest/
You will want to use NSURLRequest to post data to a PHP file on your server. There are also some libraries out there such as http://allseeing-i.com/ASIHTTPRequest/ which you could use instead.

Categories