Using $_GET on Scriptcase: On this tutorial we are going to show how to create a form application that will use a grid application to automatically fill form’s fields using only programming to pass parameters between applications.

To do so, we will send the parameters by URL using the $_GET[] array.

Step #1 – Creating MySQL Tables

a. Table of Users:

CREATE TABLE Users(
id_user INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
age INT,
email VARCHAR(20),
city VARCHAR(20),
PRIMARY KEY( ID )
)

b. Table of Sales:

CREATE TABLE Sales(
id_sales INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
email VARCHAR(20),
description VARCHAR(60),
value FLOAT,
date DATE,
PRIMARY KEY( ID ),
)
Step #2 – Creating and Configuring the applications:
a. We are going to create a form application for Sales and a grid appliation for Users.
b. On grid applicaitons lets define the parameters that will be sent by URL.

I. Create a field, called “link”, to be used as link to redirect you to the form application with parameters.

II. On the onRecord event we will define the field {link} with form application’s path concatenating with the variables that will be sent.

Code: {link} = “<a href=’http://127.0.0.1:86/scriptcase/app/my_project_name/form_sales/form_sales.php?name=”.{nome}.”&email=”.{email}.”‘>insert</a>”;

III. This way we’ve created variables called “name” and “email”

c. On form’s application let’s create a virtual field to redirect to grid’s application.

I. Creating a virtual field as Label, called “link”

II. On the onApplicationInit event we are going to use the macro sc_apl_conf(‘form_vendas’,’start’,’new’); to force the form to start in the inclusion mode.

III. On the onLoad event use the code below to redirect to the grid’s application.

Code: {link} = “<a href=’http://127.0.0.1:86/scriptcase/app/my_project_name/grid_users/grid_users.php’>Search</a>”;

IV. Still on onLoad event lets populate the fields with the variables sent by grid’s URL.

Code: {id_user} = $_GET[‘id_user’];
{name} = $_GET[‘name’];
{email} = $_GET[’email’];

On this tutorial we are going to show how to create a form application that will use a grid application to automatically fill form’s fields using only programming to pass parameters between applications.

To do so, we will send the parameters by URL using the $_GET[] array.

Step #1 – Creating MySQL Tables

a. Table of Users:

CREATE TABLE Users(
id_user INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
age INT,
email VARCHAR(20),
city VARCHAR(20),
PRIMARY KEY( ID )
)

b. Table of Sales:

CREATE TABLE Sales(
id_sales INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
email VARCHAR(20),
description VARCHAR(60),
value FLOAT,
date DATE,
PRIMARY KEY( ID ),
)
Step #2 – Creating and Configuring the applications:
a. We are going to create a form application for Sales and a grid appliation for Users.
b. On grid applicaitons lets define the parameters that will be sent by URL.

I. Create a field, called “link”, to be used as link to redirect you to the form application with parameters.

II. On the onRecord event we will define the field {link} with form application’s path concatenating with the variables that will be sent.

Code: {link} = “<a href=’http://127.0.0.1:86/scriptcase/app/my_project_name/form_sales/form_sales.php?name=”.{nome}.”&email=”.{email}.”‘>insert</a>”;

III. This way we’ve created variables called “name” and “email”

c. On form’s application let’s create a virtual field to redirect to grid’s application.

I. Creating a virtual field as Label, called “link”

II. On the onApplicationInit event we are going to use the macro sc_apl_conf(‘form_vendas’,’start’,’new’); to force the form to start in the inclusion mode.

III. On the onLoad event use the code below to redirect to the grid’s application.

Code: {link} = “<a href=’http://127.0.0.1:86/scriptcase/app/my_project_name/grid_users/grid_users.php’>Search</a>”;

IV. Still on onLoad event lets populate the fields with the variables sent by grid’s URL.

Code:

{id_user} = $_GET[‘id_user’];
{name} = $_GET[‘name’];
{email} = $_GET[’email’];
Step #3 – Run the application:

a. Run the form application. It is possible to see that the fields are blank . Click on “search”.
b. When you’ve been redirected to grid’s application choose one register to use, clicking on “Insert”.
c. Check that the fields which were on blank situation, are now filled with chosen values.

Visit our blog and check out more content!
Know Scriptcase?

By ,

November 10, 2015

a

You might also like…

No-code: Ease or Trap? What no one tells you about creating without coding

With the popularization of No-code and Low-code platforms, application development has reached a po...

Top 10 Rapid App Development Tools You Need to Know

In this highly fast-moving digital world, rapid application development tools must be available to ...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.