POST_[] RESULT to TEXT FIELD
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
POST_[] RESULT to TEXT FIELD
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
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
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: POST_[] RESULT to TEXT FIELD
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
Hi there,ghettocottage wrote: ↑Sat Aug 18, 2018 4:25 pmAssuming 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
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
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: POST_[] RESULT to TEXT FIELD
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
ghettocottage wrote: ↑Sat Aug 18, 2018 8:46 pmWell, 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
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.
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
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.SparkOut wrote: ↑Sun Aug 19, 2018 7:57 amLC 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.
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.
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: POST_[] RESULT to TEXT FIELD
Code: Select all
<input type="text" name="textname" value="<?lc put $_POST["this"] ?>
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: POST_[] RESULT to TEXT FIELD
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.