-2
  1. My C++ program communicates to my PHP server through a TCP socket.
  2. Data is sent on the server at periodic intervals.
  3. I want the Data sent on the server to be displayed on my HTML page.

I am new to HTTP/PHP programming. How can I achieve this.

Thanks in advance.

Ansh David
  • 654
  • 1
  • 10
  • 26
  • You need to revise this question, you don't say if your storing the data in a database or some other persistent storage method once your data gets to PHP. You need to give more details on the exact nature of your setup in order for a better response. – Matthew Jul 18 '14 at 10:50
  • no I do not store my data. simple `write` from c++ and `read` in php – Ansh David Jul 18 '14 at 10:51
  • How are you writing your data to PHP? The question you have asked is just way too vague and ambiguous. You need to provide more detail. – Matthew Jul 18 '14 at 10:53
  • through a TCP socket, c++ `write(cid, &msg, strlen(msg));` and on the php server `$data = socket_read($sockses, 1024)` – Ansh David Jul 18 '14 at 10:58
  • Im removing my awnser since this entire question seems to be a downvote spree and nothing more than that. – Azrael Jul 18 '14 at 11:00

2 Answers2

2

There are a lot of ways to do this, the most simple should be this one (if your c++ program run out of the server):

create a "upload.php" file in your server with:

<?php
  $a = $_POST["data"];
  //$a contains all your data
?>

send a POST message to

http://yourserver/upload.php

from your c++ program with 'data' parameter containing your data message. You can use libcurl to achieve this. Here is an example How do you make a HTTP request with C++?

Community
  • 1
  • 1
TlmaK0
  • 3,578
  • 2
  • 31
  • 51
0

c++ to PHP use Socket

PHP to HTML use HTTP

To run PHP you will need to install apache.

Jugal
  • 77
  • 7