CurtisM Posted February 1, 2008 Share Posted February 1, 2008 (I realized I had posted this in the wrong place at first and requested that the other one be closed) I have been fiddling with this for 2 days and still cannot get the data to dump to a variable or array. I am trying to get data from this post data into a variable: POST /highscore HTTP/1.1 Host: trials02.ifap4u.com:80 User-Agent: Test 2 (WIN32) Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: close Content-Type: multipart/form-data; boundary=---------------------------1641204588873 Content-Length: 2270 -----------------------------1641204588873 Content-Disposition: form-data; name="track" 12968487 -----------------------------1641204588873 Content-Disposition: form-data; name="faults" 0 -----------------------------1641204588873 Content-Disposition: form-data; name="time" 1803 -----------------------------1641204588873 Content-Disposition: form-data; name="name" test -----------------------------1641204588873 Content-Disposition: form-data; name="key" XXXXX-XXXXX -----------------------------1641204588873 Content-Disposition: form-data; name="pcid" -0000000000 -----------------------------1641204588873 Content-Disposition: form-data; name="version" 3867393 -----------------------------1641204588873 Content-Disposition: form-data; name="build" 27 -----------------------------1641204588873 Content-Disposition: form-data; name="recording"; filename="100binary" Content-Type: application/octe Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/ Share on other sites More sharing options...
trq Posted February 1, 2008 Share Posted February 1, 2008 Posted data automatically ends up in the $_POST array while uploaded files will be within the $_FILES array. Is this what your looking for? Your question, or lack there of, is pretty vague. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455017 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 Posted data automatically ends up in the $_POST array while uploaded files will be within the $_FILES array. Is this what your looking for? Your question, or lack there of, is pretty vague. I have tried the basic methods for getting POST data but all of them have turned up nothing. Sorry, I am extremely tired. I can get data from basic POST's but I cannot get data for posts using "Content-Disposition". Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455020 Share on other sites More sharing options...
trq Posted February 1, 2008 Share Posted February 1, 2008 Its still not clear exactly what your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455037 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 Its still not clear exactly what your trying to do. Let me try one more time: I have a game that posts score data to a script with the multipart/form-data ENCTYPE, but I cannot get my php script to parse the data that was posted to it. So I am looking for help on how to accomplish this in my php script. I cannot change how the game posts the data though. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455080 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 Still no one? Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455327 Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 Please post your code. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455330 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 As of now, this is what I have: <? $data = file_get_contents("php://input"); $fh = fopen("data.txt", 'w') or die(); fwrite($fh, $data); fclose($fh); $cmd = $_GET['cmd']; if($cmd == "registername"){ echo "OK"; }else{ echo $data; } ?> I have it write the output of it's operations to "data.txt" so that I can view the posted data from the game. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455337 Share on other sites More sharing options...
rhodesa Posted February 1, 2008 Share Posted February 1, 2008 yeah...php should automatically parse it and store it in $_POST Try this and see what get's stored in data.txt: <?php $data = file_get_contents("php://input"); $fh = fopen("data.txt", 'w') or die(); //fwrite($fh, $data); fwrite($fh,var_export($_POST,true)); fclose($fh); $cmd = $_GET['cmd']; if($cmd == "registername"){ echo "OK"; }else{ echo $data; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455340 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 yeah...php should automatically parse it and store it in $_POST Try this and see what get's stored in data.txt: Just got: array ( ) Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455348 Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 Please post your form Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455350 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 Please post your form Ken There is no form, it is posted by a game of mine, but if you look at the first post it shows the post data from the application. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455515 Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 If there is no form, please tell us how you're generating the POST information. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455540 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 If there is no form, please tell us how you're generating the POST information. Ken It is being generated in the game then winsock POSTS the data to my scipt; a full output of it is posted at the top. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455601 Share on other sites More sharing options...
trq Posted February 1, 2008 Share Posted February 1, 2008 Ok, so youve got the data that was posted into a text file. What do you want to parse out of it? And what exactly do you want to do with this data? Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455702 Share on other sites More sharing options...
CurtisM Posted February 1, 2008 Author Share Posted February 1, 2008 Ok, so youve got the data that was posted into a text file. What do you want to parse out of it? And what exactly do you want to do with this data? I want to get the value of "track" out of this part of the data for example: -----------------------------1641204588873 Content-Disposition: form-data; name="track" 12968487 The value would be "12968487". I just want it to go to a variable and then I have already written a script to write it to a database. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455711 Share on other sites More sharing options...
trq Posted February 1, 2008 Share Posted February 1, 2008 Replace your current script with... <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $var = $_POST['track']; } // $var now contains 12968487 re your example. ?> Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455718 Share on other sites More sharing options...
rhodesa Posted February 2, 2008 Share Posted February 2, 2008 If you check out the early comments, I had him dump $_POST and it was empty. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455724 Share on other sites More sharing options...
CurtisM Posted February 2, 2008 Author Share Posted February 2, 2008 Replace your current script with... <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $var = $_POST['track']; } // $var now contains 12968487 re your example. ?> As rhodesa said, I have already tried dumping all post data. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455728 Share on other sites More sharing options...
kenrbnsn Posted February 2, 2008 Share Posted February 2, 2008 Have you tried to see the HTTP headers that are being sent to your script. Try capturing them using the Firefox plug-in Live HTTP Headers. Maybe there are errors being generated which you're not seeing and are causing your script not to get anything. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455731 Share on other sites More sharing options...
CurtisM Posted February 2, 2008 Author Share Posted February 2, 2008 Have you tried to see the HTTP headers that are being sent to your script. Try capturing them using the Firefox plug-in Live HTTP Headers. Maybe there are errors being generated which you're not seeing and are causing your script not to get anything. Ken Thanks for the advice, but it still didn't help. I have it setup in such a way that if any PHP errors showed up they are emailed to me as well as any data being pushed out just be sure that I don't miss anything. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455739 Share on other sites More sharing options...
kenrbnsn Posted February 2, 2008 Share Posted February 2, 2008 The errors I'm talking about might be occurring before your script gets invoked, so you wouldn't see any PHP errors. If you've captured the HTTP headers, can you post them here? Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455746 Share on other sites More sharing options...
CurtisM Posted February 2, 2008 Author Share Posted February 2, 2008 The errors I'm talking about might be occurring before your script gets invoked, so you wouldn't see any PHP errors. If you've captured the HTTP headers, can you post them here? Ken Sure, I think these are what you're looking for, I'm not sure though: POST /highscore HTTP/1.1 Host: trials02.ifap4u.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: __qca=1198818578-32245428-7908646 Cache-Control: max-age=0 HTTP/1.x 200 OK Date: Sat, 02 Feb 2008 00:34:04 GMT Server: Apache/2.0.52 (Red Hat) X-Powered-By: PHP/5.2.2 Content-Length: 0 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Content-Type: text/html Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455751 Share on other sites More sharing options...
kenrbnsn Posted February 2, 2008 Share Posted February 2, 2008 If those are the entire headers, then there's the problem... The first header which is the POST header is showing no data being posted. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455753 Share on other sites More sharing options...
CurtisM Posted February 2, 2008 Author Share Posted February 2, 2008 If those are the entire headers, then there's the problem... The first header which is the POST header is showing no data being posted. Ken Those are, I just used a blank post statement. I cannot capture the actual data because it is being posted via winsock in a game. As for those, all I have is the headers from page 1. Quote Link to comment https://forums.phpfreaks.com/topic/88839-getting-data-from-content-type-form-data-type-post/#findComment-455758 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.