1

I'm totally new to this and to be honest I'm struggling to even find any basic documentation/tutorials on the subject.

I'm using Embacadero HTML5 Builder to try and create an iphone basic app

I have a basic form with 2 edit boxes and a button. All I'm trying to do is when the user clicks the button, it takes the username and password from the edits and trys to connect to a sql server (2012).

I know the IP address of the server and the database name.

If the connection fails due to incorrect logon, then a warning message is displayed. If the connection works, then it should open up the "next" page, whatever that is.

All I have so far, which I know doesn't work is below, but you get the general gist.

function btnLoginClick($sender, $params)
{
    $mysqlsvr = new SQLConnection('10.10.1.27', $edUsername.Text, $edPassword.Text, 'exp_main');
    $mysqlsvr.open;

    if fails then
        WARNING
    else
        Open new page
}

I'd like to pass this database connection through if connects fine, or just store it somewhere globally for use.

Thanks

Kromster
  • 7,181
  • 7
  • 63
  • 111
mikelittlewood
  • 223
  • 4
  • 15

1 Answers1

2

Accessing the user input

You are using the wrong identifiers to access the username and password entered by the user.

$text = $this->ComponentName->Text; // Right.
$text = $ComponentName.Text; // Wrong.

Connecting to an MSSQL server

To configure an MSSQL connection with HTML5 Builder, follow these pages of the documentation:

HTML5 Buider also includes a tool, the Data Explorer, which you can use to connect the IDE itself to your server, so you can drag and drop tables into the Designer to generate the components for the connection, instead of creating and configuring those manually.

PHP

Finally, I see you are using Delphi-like code for your event handler. HTML5 Builder is an Embarcadero product, yes, but it uses web programming languages such as JavaScript or PHP. For server-side event handlers, you must use the latter.

While you do not need a high level of PHP for using HTML5 Builder, you should learn the basics. The H5B documentation includes some pages with references to PHP documentation resources and tutorials. I would start with the W3Schools Tutorial, which will give you the basics, and you will find out the official PHP documentation, while a bit messy in some aspects, is really helpful and convers almost everything you might ever need.

Gallaecio
  • 3,620
  • 2
  • 25
  • 64
  • Hi Gallaecio, That's great thanks, total new way of coding for me so somewhere I can check out the basics is good. – mikelittlewood Sep 26 '12 at 08:45
  • I forgot to say Gallaecio. I know I can set the properties in the designer to connect to the database, but I want to set the username and password on the object from the edit boxes on the form, then set the connected property of the object to true. I can't connect to the db on startup as I don't know who the user will be. If I wrote it in delphi it would look something like this. – mikelittlewood Sep 26 '12 at 09:06
  • function btnLoginClick($sender, $params) { dmMain.Username := edUsername.Text; dmMain.UserPassword := edPassword.Text; try dmMain.Connected := True; LoadNextPage; except ShowMessage('You dont have access') end; } – mikelittlewood Sep 26 '12 at 09:11
  • Hmmm that didn't format like before but hopefully you can read it and understand what I am getting at. – mikelittlewood Sep 26 '12 at 09:12
  • Ok I understand how to pass the information through to my object $this->dmMain->UserName = $this->edUsername->Text; $this->dmMain->UserPassword = $this->edPassword->Text; $this->dmMain->Connected = True; Now need to find out about handling a successful or not connection. Thanks for your help – mikelittlewood Sep 26 '12 at 11:12
  • @Gallaecio I still have H5B in use, but now I had to upgrade to PHP 5.6+ and the mysql db connection does not work anymore. Have you an idear what I have to change? Is it not compatible anymore with PHP 5.6+ ( I know that mysql changed to mysqli / PDO in PHP. Any help what to do?) Thanks – Walter Schrabmair Nov 20 '17 at 07:15