Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Easy way to submit form data to an SQL db?

[ Edited ]

Hi all,

     I have a little bit of experience from school assignments with submitting data via a php script. This included the db login info and what to do in case of not being able to connect to the server. 


I took a look at the How I would call a web service from webworks app thread but I don't understand alot of it(the scripts, SOAP, JSON, etc). The php code I used before was pretty basic and readable. Is there an easier/more understandable way of doing this? I'm just trying to submit form data to an sql server(while also putting the data in an offline queue). To make matters more complicated, the people i'm working for are not sure if they have a perl or php script server.


This is what i'm familiar with:

The html form code:



<form action="insert.php" method="post">

Firstname: <input type="text" name="firstname" />

Lastname: <input type="text" name="lastname" />

Age: <input type="text" name="age" />

<input type="submit" />





the sql connection code, insert.php


$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("my_db", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Age)

if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo "1 record added";



Could I simply do something like that? Can I just include all of this on the client side? Some kind of javascript would be the best solution if possible.That's what I have the most control over at this point(in terms of what technology we'll be using)


Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Easy way to submit form data to an SQL db?



This is a great question. I am having difficult posting to a remote server using an AJAX call from my webworks app, which returns something if the asynchronous post was successful. See my original thread(no replied there yet):


I believe the main issue is making a call from a WebWorks app from a domain(your PlayBook) that is not "alive" on the same server(or web address), as the source of youwe WebWorks app is stored locally vs. remotely. So calling your php (or other server script) is tricky. There are browser limitations. The issue of origin being one...

Cross-domain server calls, is the technical name.

Hope someone can contribute to this thread. It will allow developers trying to bridge the gap between their existing web skill-set and better integrate with core tablet features.


Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: Easy way to submit form data to an SQL db?

[ Edited ]

In order to beat the cross-origin problem, simply  use JSONP.  It works fine as long as you don't transfer sensitive data.

Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Easy way to submit form data to an SQL db?

Can you post an example of client-side javascript code that would call a remote script?