I am using Norbert's code to send data to a form. The web returns the form's code but the form does not appear to receive the data I am sending.
Executing the form using a browser works just fine. In the example php I have posted I simply write to file but I also have php code using sql to update a mysql database. This also works just fine. using the browser
Any help is appreciated.
Web Form File
============
<form action="params_login.php" method="post" enctype="multipart/form-data" id="testparams">
<p>User<input name="user" type="text" value="<?php if (isset($_POST['user'])) echo $_POST['user']; else echo "Enter username here!";
<p>License Key<input name="license" type="text" value="example key" /> </p> <p>Last Used Date<input name="lastdate" type="date" value="2021-11-03" /> </p>
<p><input type="submit" name="Submit" value="Send" /> </p>
</form>
Web Action File
=============
<?php
$User = $_POST['user'];
$Submit = $_POST['Submit'];
$f=fopen("Login.txt","a");
fwrite($f,"-----\r\n");
fwrite($f,"$User\r\n");
fwrite($f,"$Submit\r\n");
fwrite($f,"-----\r\n");
fclose($f);
VO Code
=======
LOCAL oHttp AS cHttp
LOCAL cPage AS STRING
LOCAL cServer AS STRING
LOCAL cFolder AS STRING
LOCAL cData AS STRING
LOCAL cHeader AS STRING
cServer := "192.168.0.110"
cFolder := "/goals-master/params_rcv.php"
cData := "user=Nick Vlachou&license=XXXX-AAAA&lastdate=2021-01-01&Submit=Send"
cHeader := "Accept: *" + "/" + "*" + CrLf + ;
"Content-Type: application/x-www-formurlencoded" + CrLf + ;
"Accept-Encoding: gzip, deflate" + CrLf +CrLf
oHttp := cHttp{"TestPOST"}
cPage :=oHttp:GetDocumentByGetOrPost(cServer,cFolder, cData, cHeader, "POST", ;
/*INTERNET_DEFAULT_HTTPS_PORT*/, /*INTERNET_FLAG_SECURE */ )
FabMessageInfo( "GetorPost Result: " + CRLF + cPage )
oHttp:CloseRemote()
oHttp:Axit()
RETURN
// send data
// The dashes before and after the last boundary value,
// as well as the positioning of the CrLf variables
// is critical to the successful functioning of this process.
// Also, if you plan on posting binary data to the form,
// run the data through the Base64 algorithm.
cPostData := "--" + cBoundary + CrLf +;
[Content-Disposition: form-data; name="user" + CrLf + CrLf +;
[Nick Vlachou] + CrLf +;
"--" + cBoundary + CrLf +;
[Content-Disposition: form-data; name="license"] + CrLf + CrLf +;
[XXXX-AAAA] + CrLf +;
"--" + cBoundary + CrLf +;
[Content-Disposition: form-data; name="lastdate"] + CrLf + CrLf +; [2021-01-01] + CrLf +;
"--" + cBoundary + CrLf +;
[Content-Disposition: form-data; name="Submit"] + CrLf + CrLf +;
[Send] + CrLf +;
"--" + cBoundary + "--"
cPage := oHttp:GetDocumentByGetOrPost( "www.myserver.com",; "/test/webapp.asp?TCI=schema&RSE=Upload",;
cPostData,;
cHeader,;
"POST",;
/*INTERNET_DEFAULT_HTTPS_PORT*/,;
/*INTERNET_FLAG_SECURE*/)
Hope this will help you
Norbert
My question is, can I get the form action to execute once the form has received the cPostData or do I need to include all the code in the form?
Your code has been a lifesaver for me in the past and from the plethora of posts, it seems that many others have benefited from your support.
Thanks Norbert.
Hi Nick!
If I have understood you correctly, you are sending the data to a page written in php with the submit. This page should check the submitted parameters and only process them if the values are correct. Otherwise it should return an error message.
Thank you for your kind words. Yes, I have been able to help some people
with this and I am happy to do so if I can.
Kind regards
Norbert
My question is, can I get the form action to execute once the form has received the cPostData or do I need to include all the code in the form?
Your code has been a lifesaver for me in the past and from the plethora of posts, it seems that many others have benefited from your support.
Thanks Norbert.
Hi Norbert
Yes, your understanding is correct.
The problem I have encountered is that the url with the <form> works just fine as long as the logic is stored in this file.
<form action="somefile.php" etc ect </form> fires the action if I run this file from a browser, however, sending the requests via cavo/getorpost the somefile.php does not get called.
I would normally write my logic in files separate from the file containing the <form><fields> but sending the requests via cavo I can only access the $_POST variables in the file containing the <form>.
Simply put, if I could fire the submit button in the form, everything would work as expected.
The end target is to monitor when my_cavo_application.exe is being used by updating a database on the server.
Perhaps there is a better alternative but I haven't had time to investigate.
Hi Nick!
Did you write the web page with the form yourself or is it a page from
the web? It might help if you go to the page with the form for the data first. If this is a public URL, then send me (by mail) the data and I
look at it. Often there are additional hidden variables.
Let's see what else I can do.
Kind regards
Norbert
Am 24.02.2021 um 16:12 schrieb Nick Vlachou:
Hi Norbert
Yes, your understanding is correct.
The problem I have encountered is that the url with the <form> works just fine as long as the logic is stored in this file.
<form action="somefile.php" etc ect </form> fires the action if I run this file from a browser, however, sending the requests via cavo/getorpost the somefile.php does not get called.
I would normally write my logic in files separate from the file containing the <form><fields> but sending the requests via cavo I can only access the $_POST variables in the file containing the <form>.
Simply put, if I could fire the submit button in the form, everything would work as expected.
The end target is to monitor when my_cavo_application.exe is being used by updating a database on the server.
Perhaps there is a better alternative but I haven't had time to investigate.
Hi Norbert
I have written all the code myself, cavo, html, php.
As soon as I can, I will send you details for you to test.
Thanks,
Nick
On Thursday, February 25, 2021 at 7:17:55 AM UTC+8, nk wrote:
Hi Nick!
Did you write the web page with the form yourself or is it a page from
the web? It might help if you go to the page with the form for the data first. If this is a public URL, then send me (by mail) the data and I
look at it. Often there are additional hidden variables.
Let's see what else I can do.
Kind regards
Norbert
Am 24.02.2021 um 16:12 schrieb Nick Vlachou:
Hi Norbert
Yes, your understanding is correct.
The problem I have encountered is that the url with the <form> works just fine as long as the logic is stored in this file.
<form action="somefile.php" etc ect </form> fires the action if I run this file from a browser, however, sending the requests via cavo/getorpost the somefile.php does not get called.
I would normally write my logic in files separate from the file containing the <form><fields> but sending the requests via cavo I can only access the $_POST variables in the file containing the <form>.
Simply put, if I could fire the submit button in the form, everything would work as expected.
The end target is to monitor when my_cavo_application.exe is being used by updating a database on the server.
Perhaps there is a better alternative but I haven't had time to investigate.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 292 |
Nodes: | 16 (2 / 14) |
Uptime: | 206:41:03 |
Calls: | 6,618 |
Calls today: | 2 |
Files: | 12,168 |
Messages: | 5,316,890 |