POST Form values to server (PHP)


#1

Good day,
I am in the process of moving from a different environment to NSB App Studio.
In my previous environment I would have a Form with a number of Input boxes defined. example:
input type=“text” name=“username” id=“username” placeholder=“Username”>
input type=“password” name=“password” id=“password” placeholder=“Password”>
input type=“submit” value=“Submit”>
The Submit Button then POST the values by id to the server example:
form name=“userform” id=“register” action=“http://xxx.xxx.xxx.xxx/CheckPWD.php” method=“POST”>

The PHP script would receive and process the POST:

<?php $fname = $_POST['username']; $fpassword = $_POST['password']; I am currently trying the Ajax examples and can only manage to get one POSt or GET value to the server. I would typically need to pass multiple values (different variables) to a PHP script. Can anyone help? kind regards Zack

#2

The Ajax samples use explicit Ajax functions to call the PHP script, rather than the implied call the Form Submit uses. It’s more flexible.

http://wiki.nsbasic.com/Ajax

A URL with multiple arguments would look like this:

http://xxx.xxx.xxx.xxx/CheckPWD.php?username=ghenne&password=1111

Use ? for the start of the arguments and & between them. Of course, there are fancier options as well.


#3

Good day all!
Just to share the syntax that works for me.
req = Ajax(“http://xxx.xxx.xxx.xxx/CheckPWD/CheckPWD.php”, “POST” , “username=” + TextBox1.value + “&password=” + TextBox2.value, done);


#4

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.