Source language: Translate to:

neoapptest.php (form submit )

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

neoapptest.php (form submit )

Postby caroApp » Wed May 20, 2015 11:00 am

Neoapp is Great ! and waiting the Release date as christmas! :)

I declared the following variabe on the php script from server side and wanted to capture it with neoapp variable .

Code: Select all
$output = "42Alberts";


I may echo it directly to the form from the server with the following code..

Code: Select all
$output = "42Alberts";
   echo htmlspecialchars($output);


Instead i want to capture and put in the variable [datafrommyserver] to use it
in neoapp . maybe save it in Local storage .

ideas ? I'm stuck here although it may be easy i guess if i dig more .... :wink:
caroApp
 
Posts: 4
Joined: Tue May 19, 2015 3:49 am

Re: neoapptest.php (form submit )

Postby PaulTomo » Wed May 20, 2015 4:52 pm

I have been doing some php work with NeoApp Builder.

Try using this on the server php script:
Code: Select all
$output = "42Alberts";
//Any other stuff etc etc
echo $output;


Then within NeoAppBuilder it can be displayed on screen in a container:
Code: Select all
SetObjectHTML "Container1" [Data]

Or just put it in to a variable to use later:
Code: Select all
SetVar [datafrommyserver] [Data]


I think anything returned after a form is submitted is returned to the following NeoAppBuilder variables:
.success event passes in two parameters
[data] = information returned by server
[status] = status code returned by server (200=OK)


I hope this helps.
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: neoapptest.php (form submit )

Postby caroApp » Thu May 21, 2015 12:05 am

Dont work ! :mrgreen: I Tried that before posting . Maybe Bugs problem .
simply put the following code in the button and try it ...... you will get " Undefined " !
Code: Select all
SetObjectHTML "Container1" [Data]


the echo displays all you have got to your form or container . I am focusing just to retrieve one variable and put it in Neoapp variable .
caroApp
 
Posts: 4
Joined: Tue May 19, 2015 3:49 am

Re: neoapptest.php (form submit )

Postby Gaev » Thu May 21, 2015 6:23 am

caroApp:

Can you post the code in your NeoApp that makes the AJAX call (GET/PUT) to your php script ... including the callback function that receives the response ?
User avatar
Gaev
 
Posts: 3717
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: neoapptest.php (form submit )

Postby PaulTomo » Thu May 21, 2015 6:40 am

I have been playing around with SQL DBase queries, these are being returned and filling in forms without any problems using php in this way.

I have tried it, just as you suggested and I get "42Alberts" displayed in the container and variable if I press the Submit Button (Test).

Image

Maybe that's not what you are after and I must be misunderstanding what it is you are actually trying to do from your question?

Sorry about that and Good Luck sorting it out.
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: neoapptest.php (form submit )

Postby caroApp » Thu May 21, 2015 11:48 am

Paul !
I have been playing around with SQL DBase queries, these are being returned and filling in forms without any problems using php in this way.


it may work from SQL which i am intending to do next , However my problem is Very Simple .

Just to pass the variable which is echoed by the php script to Neoapp local variable .

in my first post i used another echoing method . now .....
Code: Select all
ob_start();
echo 'Hello World';  //  to pass  Variable  $toNeoapp  to neoapp Local variable
$toNeoapp = ob_get_contents();
ob_end_clean();


Gaev !

I did not change anything except in the php script . as shown in the code below
everything works well ! and all varaibles including $toNeoapp shows with assigned value " Hello world "
here i want to put the results "Hello world" to Neopp local Variable .


the php script code ::
Code: Select all
<?php
//Header required when app and php are of different origins
header("Access-Control-Allow-Origin: *");


ob_start();
echo 'Hello World';  //  to pass  Variable  $toNeoapp  to neoapp Local variable
$toNeoapp = ob_get_contents();
ob_end_clean();


if ($_SERVER["REQUEST_METHOD"] === "POST") {
  if (isset($_POST["firstName"]) && isset($_POST["lastName"])) {
    // Correct form submission

   $result = "DATA RECEIVED BY SERVER 
"
      "
First Name = " . $_POST["firstName"] .
      "
Last Name = " . $_POST["lastName"] .
     "
Email = " . $_POST["age"] .
     "
To neopp = " . $toNeoapp .
     "
Gender = " . $_POST["gender"];

 } else {
    $result = "INVALID REQUEST DATA";
  }
} else {
    $result = "INVALID REQUEST DATA";
  }

echo $result;
?>




Thanks!
caroApp
 
Posts: 4
Joined: Tue May 19, 2015 3:49 am

Re: neoapptest.php (form submit )

Postby Neosoft Support » Fri May 22, 2015 10:13 am

Try running your PHP script directly in a browser and see if it works there. If it contains errors, it will fail and won't return any data.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: neoapptest.php (form submit )

Postby caroApp » Sat May 23, 2015 11:38 pm

Neosoft Support wrote:Try running your PHP script directly in a browser and see if it works there. If it contains errors, it will fail and won't return any data.


Yes ! it works . my last php wont return in the browser but returns to the object Container1 in Neoapp. The reason is the php command sents the echo only to the calling application .
but my first post of my php returns data to the container and browser .
here is the script to try it

Code: Select all
<?php
//Header required when app and php are of different origins
header("Access-Control-Allow-Origin: *");
 

$output = "42";
       echo htmlspecialchars($output);

if ($_SERVER["REQUEST_METHOD"] === "POST") {
  if (isset($_POST["firstName"]) && isset($_POST["lastName"])) {
    // Correct form submission
    $result = "DATA RECEIVED BY SERVER:" .
      "
First Name = " . $_POST["firstName"] .
      "
Last Name = " . $_POST["lastName"] .
      "
Age = " . $_POST["age"] .
       "
VariableApp = " . $output .   

       "
Gender = " . $_POST["gender"];

     
  } else {
    $result = "INVALID REQUEST DATA";
  }
} else {
    $result = "INVALID REQUEST DATA";
  }

echo $result;
?>



Again my simple question is how to retrieve the specific " $output " variable to Neoapp Local Variable ?
caroApp
 
Posts: 4
Joined: Tue May 19, 2015 3:49 am

Re: neoapptest.php (form submit )

Postby Neosoft Support » Mon May 25, 2015 10:50 am

I tried your PHP script here with NeoAppBuilder and it works. You have to upload the PHP file to your server and set the Form object's "action" property to point to it. PHP scripts cannot be run from a local PC.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron