Page 1 of 1

POST_[] RESULT to TEXT FIELD

Posted: Sat Aug 18, 2018 12:56 pm
by istech
Hi Livecoders,

Just starting to play with Livecode server and want to POST[] a result to a specific input field on an HTML page.

Very similar to php version <input type="text" name="textname" value="<?php echo $_POST['textnameresult'] ?>" />

If someone could enlighten me that would be great.

Many thanks

Re: POST_[] RESULT to TEXT FIELD

Posted: Sat Aug 18, 2018 4:25 pm
by ghettocottage
Assuming your variables are "tThis" and "tThat" and "tOther"

Code: Select all

    
    put  "https://yoururl.com"  into gURL
    
    put "this=" & tThis & "&that=" & tThat & "&tid=" & tOther into tStuffToPost   
      
      --post it to the server
      post tStuffToPost to URL gURL
      
      
      --decode the response
      put it into tResults
      
      

Re: POST_[] RESULT to TEXT FIELD

Posted: Sat Aug 18, 2018 7:33 pm
by istech
ghettocottage wrote:
Sat Aug 18, 2018 4:25 pm
Assuming your variables are "tThis" and "tThat" and "tOther"

Code: Select all

    
    put  "https://yoururl.com"  into gURL
    
    put "this=" & tThis & "&that=" & tThat & "&tid=" & tOther into tStuffToPost   
      
      --post it to the server
      post tStuffToPost to URL gURL
      
      
      --decode the response
      put it into tResults
      
      
Hi there,

Thanks for the response. Just to confirm using my example. If my post looks like:

put "Result" into textnameresult
put "name="testname" & "value=" & textnameresult into tStuffToPost
post tStuffToPost to URL gURL

This should post "Result" to field name testname?

Thanks

Re: POST_[] RESULT to TEXT FIELD

Posted: Sat Aug 18, 2018 8:46 pm
by ghettocottage
Well, it depends on what your application on the webserver looks like. Is it PHP? Do you have access to the script it is sending to?

Re: POST_[] RESULT to TEXT FIELD

Posted: Sun Aug 19, 2018 7:03 am
by istech
ghettocottage wrote:
Sat Aug 18, 2018 8:46 pm
Well, it depends on what your application on the webserver looks like. Is it PHP? Do you have access to the script it is sending to?

Hi there,

Yes, it's a simple .lc script I created that I post to and want the result to be displayed in a text box on the same web page. My server has lc server installed so thought there was a straightforward way to do this. Will give this a go. I suppose the php way should also work as I do have php also running but thought there must be a lc way to do the same thing.

Re: POST_[] RESULT to TEXT FIELD

Posted: Sun Aug 19, 2018 7:57 am
by SparkOut
LC server can do this simply.
Php "echo" is equivalent to LC "put".

So you are not trying to fake a user filling in a webform by taking the value in the input box and posting to a url. Instead you are filling the form and posting to the same url and want to redraw the screen with the same form but already filled with the last value submitted?

I'm not sure what you are trying to achieve, but for lc, "put" will be what you need I think.

Re: POST_[] RESULT to TEXT FIELD

Posted: Sun Aug 19, 2018 8:28 am
by istech
SparkOut wrote:
Sun Aug 19, 2018 7:57 am
LC server can do this simply.
Php "echo" is equivalent to LC "put".

So you are not trying to fake a user filling in a webform by taking the value in the input box and posting to a url. Instead you are filling the form and posting to the same url and want to redraw the screen with the same form but already filled with the last value submitted?

I'm not sure what you are trying to achieve, but for lc, "put" will be what you need I think.
No fake user data being inputted. I have 2 text boxes and a submit button. Users input info into text box 1 and then press submit. Script checks details and replies either ok or error to text box 2. My problem is getting the reply to text box 2.

I just want to put $_POST["result"] into text box 2 on the current webpage.

So under php for my script to work how I want it to I would put the following into text box 2 and it should work "<input type="text" name="textname" value="<?php echo $_POST["result"] ?>" />" what is the lc equivalent?

Very similar to this lesson http://samples.on-rev.com/form.irev but I want the result to go into a text box rather than dynamically displayed.

Re: POST_[] RESULT to TEXT FIELD

Posted: Sun Aug 19, 2018 4:11 pm
by ghettocottage

Code: Select all

<input type="text" name="textname" value="<?lc put  $_POST["this"] ?>
The "result" I had put in the first code I posted is how to get the response from your remote application. You would not actually use "result" in your web-application and can ignore that bit of code if you do not need it, although it is good for error checking.

Re: POST_[] RESULT to TEXT FIELD

Posted: Sun Aug 19, 2018 4:12 pm
by ghettocottage
Also, just a thought: you can post directly to your online application and have it process your data and get a response without having to use the html form, unless you just need the person to go to the website for some reason.