3. Passing Data from a Form

Passing data from a form and retrieving it using WebDNA

numero = 155
interpreted = N
texte = Now let's interact with WebDNA: send it some data, some instructions, and see WebDNA process it. To do this, you will need two pages: one that sends the data, the other one that processes the data. (You could even do this using a single page: it would send the data to itself, and process it based on certain conditions. But let's work with two pages here.) In html, if you want to send data to a server, you use a form to POST or GET data. What is the difference? GET is the "old way": the data appears in your URL, which could be a little bit dangerous nowadays, and your limit is 256 characters. POST doesn't show anything and has no limit, so we will use POST. (Both ways are accepted by WebDNA). Let's build a basic form that sends anything you want, using simple html:
<html><form method="post" action="formprocess.dna"><input type="text" name="data" size="30"></br><input type="submit"></form></html>
This cannot be simpler :-) Let's see the formprocess.dna now: Make sure your page starts with <!--HAS_WEBDNA_TAGS--> and then, we will recover the data. What was the name of the field passing the data? "data" So, to recover your data, just do this:
<!--HAS_WEBDNA_TAGS-->[data]
Write anything you want in the form, submit, and you will see the second page, formprocess.dna, with what you wrote. Pretty simple, huh? Now, let's imagine you want to do something with the data; for instance, show a personal message to Chris and just say hello to anybody else:
<!--HAS_WEBDNA_TAGS-->[showif [data]=chris]Hi Chris? did you buy the milk?[/showif][hideif [data]=chris]Hello there![/hideif]
Let's do some math: write 4 plus 23 in the form, and
<!--HAS_WEBDNA_TAGS-->[math][data][/math]
in formprocess.dna, it will return "27" And what if your data is an email address that would send a specific email to the registered user? The subject will be "Thank you" and the message "Thank you for registering! Today is thedate" Make your formprocess.dna like this:
<!--HAS_WEBDNA_TAGS-->[SendMail to=[data]&from=me@mydomain.com&subject=Thank you]Thank you for registering! today is [date][/SendMail]
image >>> Next page... Now let's interact with WebDNA: send it some data, some instructions, and see WebDNA process it.

To do this, you will need two pages: one that sends the data, the other one that processes the data. (You could even do this using a single page: it would send the data to itself, and process it based on certain conditions. But let's work with two pages here.)

In html, if you want to send data to a server, you use a form to POST or GET data. What is the difference? GET is the "old way": the data appears in your URL, which could be a little bit dangerous nowadays, and your limit is 256 characters. POST doesn't show anything and has no limit, so we will use POST. (Both ways are accepted by WebDNA).

Let's build a basic form that sends anything you want, using simple html:
<html>
<form method="post" action="formprocess.dna">
<input type="text" name="data" size="30">
</br>
<input type="submit">
</form>
</html>

This cannot be simpler :-) Let's see the formprocess.dna now:

Make sure your page starts with <!--HAS_WEBDNA_TAGS--> and then, we will recover the data. What was the name of the field passing the data? "data"

So, to recover your data, just do this:
<!--HAS_WEBDNA_TAGS-->
[data]

Write anything you want in the form, submit, and you will see the second page, formprocess.dna, with what you wrote. Pretty simple, huh?

Now, let's imagine you want to do something with the data; for instance, show a personal message to Chris and just say hello to anybody else:
<!--HAS_WEBDNA_TAGS-->
[showif [data]=chris]Hi Chris? did you buy the milk?[/showif]
[hideif [data]=chris]Hello there![/hideif]

Let's do some math: write 4 plus 23 in the form, and
<!--HAS_WEBDNA_TAGS-->
[math][data][/math]

in formprocess.dna, it will return "27"

And what if your data is an email address that would send a specific email to the registered user? The subject will be "Thank you" and the message "Thank you for registering! Today is 04/25/2024"
Make your formprocess.dna like this:
<!--HAS_WEBDNA_TAGS-->
[SendMail to=[data]&from=me@mydomain.com&subject=Thank you]
Thank you for registering! today is [date]
[/SendMail]


image
>>> Next page... Christophe Billiottet

DOWNLOAD WEBDNA NOW!

Top Articles:

Related Readings:

Introduction

A short introduction to WebDNA programming for absolute beginner...

3. Passing Data from a Form

Passing data from a form and retrieving it using WebDNA...

4. Password Protecting

How to password-protect a page using WebDNA...

2. Conditional Programming

Conditional programming with WebDNA...

1. Learn WebDNA Programming

Learning WebDNA programming: the very basics...

6. Working with Databases

Working with WebDNA database...