• GetorPost

    From Nick Vlachou@21:1/5 to All on Mon Feb 22 08:47:19 2021
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nk@21:1/5 to All on Tue Feb 23 01:35:41 2021
    Hi Nick,

    in your php-code you use enctype="multipart/form-data" and in VO
    "Content-Type: application/x-www-formurlencoded".
    If you use multipart in VO, then cPostData must also be constructed as multipart.

    Here is the code (not tested):

    oHttp := CHttp{"VoTest"}
    // oHttp:UserName := "user"
    // oHttp:PassWord := "pw"

    // to identify the boundary something like that
    cBoundary := "--UPLOAD--BOUNDARY--huklfehnv--UPLOAD-BOUNDARY--"

    // include to the header
    cHeader := "Accept: *" + "/" + "*" + CrLf +;
    "Content-Type: multipart/form-data; boundary=" + cBoundary + CrLf +;
    "Accept-Language: de-at,de;q=0.5" + CrLf + CrLf

    // 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


    Am 22.02.2021 um 17:47 schrieb Nick Vlachou:
    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


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nick Vlachou@21:1/5 to All on Tue Feb 23 06:51:11 2021
    Hi Norbert

    Thanks so much for your early response. Certainly put me in the right direction.
    At first I could not get it to work but after displaying the cPostData on screen I found that ;name="user" was missing the closing square bracket.
    Problem was, I could not get the <form action="params_login.php" to execute. After testing the $_POST["variable name"] in the form, the cPostData was available so I moved the params_login code to the bottom of the form and it all works well.

    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?
    I suppose I could write a function to call the "params_login.php" if the submit button contains the correct value; e.g. Default="No" and cPostData could pass "Yes" or true/false.

    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.

    NV

    On Tuesday, February 23, 2021 at 8:35:45 AM UTC+8, nk wrote:

    // 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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nk@21:1/5 to All on Wed Feb 24 00:33:57 2021
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nick Vlachou@21:1/5 to All on Wed Feb 24 07:12:14 2021
    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.

    Any guidance is appreciated.

    NV

    On Wednesday, February 24, 2021 at 7:34:00 AM UTC+8, nk wrote:
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nk@21:1/5 to All on Thu Feb 25 00:17:54 2021
    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.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nick Vlachou@21:1/5 to All on Fri Feb 26 17:36:24 2021
    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.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nick Vlachou@21:1/5 to Nick Vlachou on Sat Feb 27 08:08:19 2021
    Hi Norbert

    I would like to send you some files so you can see exactly what I am trying to achieve.
    Unfortunately, the email address I used has bounced.
    Would you be so kind and send me an email so that I can send again.

    Thanks, Nick

    On Saturday, February 27, 2021 at 9:36:25 AM UTC+8, Nick Vlachou wrote:
    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.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nk@21:1/5 to All on Sat Feb 27 23:24:42 2021
    Hi Nick,

    try

    n dot kolb at chello dot at

    Norbert

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)