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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi Gallaecio, That's great thanks, total new way of coding for me so somewhere I can check out the basics is good.
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.
function btnLoginClick($sender, $params) { dmMain.Username := edUsername.Text; dmMain.UserPassword := edPassword.Text; try dmMain.Connected := True; LoadNextPage; except ShowMessage('You dont have access') end; }
Hmmm that didn't format like before but hopefully you can read it and understand what I am getting at.
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
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.