Hello everybody.
You all know the input-forms on every website where you can put text in and submit it.
I want to post some data as a string to my 'upload.php' file on my webserver.
Then I want to work with this submitted data and generate a response that goes back to the programme.
Could you give me some hints, please, how I can easily post some text to this php file.
I want to catch it on my server simply with $mytext = $POST['mystring'];
If you want to suggest me cURL, then please give me a description how I implement and link it...
I spent much time at this and didn't get it to compile.
Thank you very much!
- Eric
How to post some text to my webserver (PHP)
Re: How to post some text to my webserver (PHP)
If you just want to pass a few text variables, just add them to the url, like you would when you type the url into a browser:
Code: Select all
wxHTTP http;
http.Connect(wxT("www.someserver.nix"), 80);
wxInputStream *httpStream=http.GetInputStream(wxT("/test.php?var1=hallo&var2=wxwidgets"));
if(httpStream!=NULL) {
wxString res;
wxStringOutputStream out_stream(&res);
httpStream->Read(out_stream);
wxLogMessage(res);
delete httpStream;
}
Use the source, Luke!
Re: How to post some text to my webserver (PHP)
I discovered this way already.
But I have to post unicode-text with a lot of chars that don't match the URL-chars...
So I think I have to perform a real POST to get it, but I don't know how to do it.
But I have to post unicode-text with a lot of chars that don't match the URL-chars...
So I think I have to perform a real POST to get it, but I don't know how to do it.
Re: How to post some text to my webserver (PHP)
That would still work if you url-encode the parameters. I don't think there is any wxWidgets method for that, but it should be trivial enough to code it yourself.
You could also check out wxHTTPEngine:
http://wxcode.sourceforge.net/components/httpengine/
(class wxHTTPBuilder would be what you're looking for)
You could also check out wxHTTPEngine:
http://wxcode.sourceforge.net/components/httpengine/
(class wxHTTPBuilder would be what you're looking for)
Use the source, Luke!
Re: How to post some text to my webserver (PHP)
I would prefer a real post, not via URL.
Can I add some headers to wxHTTP?
Can I add some headers to wxHTTP?
Re: How to post some text to my webserver (PHP)
http://docs.wxwidgets.org/stable/wx_wxh ... psetheader
There is also void wxHTTP::SetPostBuffer(const wxString& post_buf)
It's not documented in 2.8.x, but it exists. But you have to build the content of the buffer yourself.
There is also void wxHTTP::SetPostBuffer(const wxString& post_buf)
It's not documented in 2.8.x, but it exists. But you have to build the content of the buffer yourself.
Use the source, Luke!
Re: How to post some text to my webserver (PHP)
I played a little bit with the cURL.exe command-line-tool. I'm satisfied
I'd like to use cURL in my project.
Can you help me at implementing it, please?
I've got no idea which files I shall copy in which directory...
I'd like to use cURL in my project.
Can you help me at implementing it, please?
I've got no idea which files I shall copy in which directory...
Re: How to post some text to my webserver (PHP)
That very much depends on the compiler/ide you're using. With Visual Studio you just add the libcurl library to your linker input files and add the libcurl include path to the compiler input directories and that's it.Can you help me at implementing it, please?
I've got no idea which files I shall copy in which directory...
I don't know about other IDEs or platforms, but i guess it should be similar.
Use the source, Luke!
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: How to post some text to my webserver (PHP)
check wxCurleriX wrote:I'd like to use cURL in my project.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?