Jump to content

decode html input string


Hodo

Recommended Posts

Probably not the correct words in the subject but I'll try to explain. I have software in c++ that sends data to a php file on my website. I have all the connections in place since it echoes back an ok to my code. Problem is the data portion is not being read by the php. I dont know how to reference it.

 

this is what I send:

data ="Hello World";

len = strlen(data);

 

POST /mydir/getmessage.php HTTP/1.1\n

Host: www.mysite.com:80\n

User-Agent: MyAgent/1.0 \n

Accept: */*\n

Content-Length: len \n

Content-Type: application/x-www-form-urlencoded; charset=UTF-8\n\n"

 

data;

 

php file on the server

 

<?php

printf("RETURN: OK %s",$Data);

?>

 

This sends back OK but not an echo of the data. Should be OK Hello World.

Can someone explain how to read the data file being sent? I would like to add a few things like name,password,etc to the data I send but not sure how to index or split it out on the php side.

 

 

 

 

Link to comment
Share on other sites

@thorpe

the data is urlencoded before I send it

 

your example returns OK as well probably because it's not parsed at the php level.

 

Here is the received data

no return HTTP/1.1 200 OK

no return Date: Wed, 13 Jun 2007 18:22:24 GMT

no return Server: Apache

no return Transfer-Encoding: chunked

no return Content-Type: text/html

no return

no return 47

no return

no return

no return <HTML>

no return <HEAD>

no return </HEAD>

no return <BODY>

OK    <<<<<<<<<<<<<<<<<<<<<< THIS IS WHAT IS PERTENIENT

no return </BODY>

no return </HTML>

 

What I need to confirm is that the data I sent is actually received.

How does php parse the input. Say I sent a data like

data = "Megaman+foofoo9";

there are 2 words in the data so in php

 

$name = firstword;

$pass = secondword;

 

I should be able to print, or echo these values to prove they got parsed.

 

@boo_lolly

This data has to be sent to a webstie and parsed there for insertion into a database or checks against a database.

 

thanks for the reply...

Link to comment
Share on other sites

@boo_lolly

 

I have a program running on my computer at the house.

when it executes a function in that c++ code calls my website and is supposed to deposit information

 

If the xml of which you speak is on the website, how does it get launched only when my program runs?

If the xml is local to my machine then again it will have to contact my website on its own and send the standard html string which causes the same problem.

 

What do you propose?

 

Link to comment
Share on other sites

the XML is not on your website. the XML document is created dynamically everytime the C++ application runs. the data that the C++ application creates will be stored in an XML document. then you can send the XML document to the website.

 

if you google XML and read a little about it, you'll soon find that it is one of, if not, the most efficient way of transfering data from one medium to another. it doesn't matter where it starts or ends. plus, it's a really good thing to know XML. it's the future.

 

questions:

what does the C++ app do exactly? what kind of data does it generate? what is it for?

Link to comment
Share on other sites

So now I have a xml formatted by c++ then I have to somehow send it to my website dynamicly. No prob, now I have to tell my php to act on it, parse the data then store the info in the database.

sounds like alot of extra work to do that as opposed to sending the data in a simple post since Im inside the winsock already and the post method has provisions to send the data in a single call the way im doing it now. Data sent is an ip address and a name. 2 pieces of info should be trivial in php but dont know how to parse the input message to get the 2 bits of data.

 

thanks for reply

 

Link to comment
Share on other sites

sounds like alot of extra work to do that as opposed to sending the data in a simple post

 

I agree.

 

Lets first see exactly what was posted to the php script.

 

What does....

 

<?php

  print_r($_POST);

?>

 

output?

Link to comment
Share on other sites

ah I smell some magic!

 

no return <HTML>

no return <HEAD>

no return </HEAD>

no return <BODY>

no return Array

no return (

no return    [data] => HYPERKAT    <<<<< THIS IS THE DATA I SENT!

no return )

no return 

no return </BODY>

no return </HTML>

no return

no return

no return 0

 

Sorry for being such a noob on this, now to extract it as a single var and put it in the file

Thanks for reply!

Link to comment
Share on other sites

What exactly is producing this output?

 

no return <HTML>
no return <HEAD>
no return </HEAD>
no return <BODY>
no return Array
no return (
no return     [data] => HYPERKAT    <<<<< THIS IS THE DATA I SENT!
no return )
no return 
no return </BODY>
no return </HTML>
no return
no return
no return 0

 

Can we see the output of...

 

<?php

  print_r($_POST);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.