POST/GET Problem lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ahiggins · 2018-03-06 17:09 Hi, I'm having issues using POST to send data from a HTML form to my Apache Module Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;  AResponse: TResponse; Var Handled: Boolean);var   Str       : String; begin     ARequest.ContentType:='APPLICATION/X-WWW-FORM- URLENCODED';     Str:='[returned data] - '+ARequest.QueryFields.Values['pname'];     AResponse.Content:=Str;   Handled:=True;end;  the above works fine if i sent the the data via a  simple form using GET Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  
 
         
 
 
 
     
  the Apache module returns the below correctly. [returned data] - Jon Doe but if i change the code to handle POST Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;  AResponse: TResponse; Var Handled: Boolean);var   Str       : String; begin     ARequest.ContentType:='APPLICATION/X-WWW-FORM- URLENCODED';     Str:='[returned data] - '+ARequest.Content;     AResponse.Content:=Str;     Handled:=True;end; and send the data with a simple html form using POST Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i
 
         
 
 
 
     
  the Apache module fails to  return any data. [returned data] - any help would be great. Tony ---------------------------------------------------------------------- heejit · 2018-03-06 20:50 Try 1. ARequest.ContentFields.Values['']; 2. Maybe input tag missing type attribute ---------------------------------------------------------------------- ahiggins · 2018-03-07 12:26 @jshah, I shall give it a try kinds regards Tony ---------------------------------------------------------------------- ahiggins · 2018-03-07 14:07 ok, I tried Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  ARequest.ContentFields.Values['pname']; still no joy. also noticed Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ARequest.ContentFields.count returns 0 any ideas are more than welcome Tony ---------------------------------------------------------------------- egsuh · 2018-03-07 14:27 Try after changing your html. type=text is missing in your example. ---------------------------------------------------------------------- rvk · 2018-03-07 14:31 And you shouldn't SET ARequest.ContentType. It's for input of the request. If you want you can set the AResponse.ContentType. B.T.W. what is the value of ARequest.ContentType when entering that event? ---------------------------------------------------------------------- ahiggins · 2018-03-07 14:37 @rvk ARequest.ContentType is application/x-www-form-urlencoded when entering the event I removed the line assigning ARequest.ContentType still no output ---------------------------------------------------------------------- rvk · 2018-03-07 14:47 Quote from: ahiggins on March 07, 2018, 03:37:32 pmI removed the line assigning ARequest.ContentType still no output No, that wasn't the problem. It was just not correct to set the ContentType of the incoming request. You need to do that on the ARepsonse (outgoing) request. But that's also not your actual problem. Try setting type=text for the input like jshah and egsuh suggested. I also missed the type=submit for the button. I wonder if the browser actually does a POST when there is no type=submit in the button tag. So put that in there too. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i
 
         
 
 
 
     
---------------------------------------------------------------------- ahiggins · 2018-03-07 15:08 @rvk set the type to text and the added submit type still not returning anything when using POST  
   
                           
---------------------------------------------------------------------- egsuh · 2018-03-07 15:20 I tested this HTML on my PC just changing "action" part (on Windows 8 ), and NO PROBLEM. I did make a web-server program displaying the content of  "contentfields" in the past (fcgi module) for testing purpose.  I do not use Apache server so the problem might lies in that part. ---------------------------------------------------------------------- ahiggins · 2018-03-07 15:49 @egsuh Starting to think its a setup issue somewhere myself, I running Debian 9 and Apache 2.2 might setup another box from scratch and see it anything changes. it just seems strange that it works with the GET method.