Whizbase fast tutorial

AID: 2597
  • Status: Published

1500 points

  • ByNurAzije
  • TypeTutorial
  • Posted on2010-03-03 at 05:55:13
Introduction

This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works.

WhizBase is a server-side scripting language, which uses simple English words for its commands. WhizBase files regularly have .wbsp extension, but it also can have .ic, .sr, .inc and other less likely.
The syntax of WhizBase is directly embedded in HTML code, for example if you want to show the current date you use:

This is the date today: $WBFN[DATE]
                                    
1:

Select allOpen in new window



Every WhizBase file is interpreted first then sent back to the browser, so this code will not show any WhizBase code in the source code of the page.

Conditional Programming

As with most server-side scripting languages, WhizBase supports conditional programming, you can write IF statements and switch case statements in WhizBase. Here is the basic syntax and examples:

$WBIF[expression|true part|false part]
                                    
1:

Select allOpen in new window



If we need to show the string "Today is Friday" only when it is Friday we use:

$WBIF[ $WBFN[WEEKDAYS] = "Friday"
|
Today is Friday
|
I am sorry today is not Friday
]
                                    
1:
2:
3:
4:
5:
6:

Select allOpen in new window



If just IF and ELSE are not sufficient (we want more than one case) we must use the CASE statement:
$WBCASE[separator|value|conditionlist|resultlist|default]
                                    
1:

Select allOpen in new window



For the seven days in the week:
$WBCASE[,|$WBFN[WEEKDAYN]
|
=1,=2,=3,=4,=5,=6,=7
|
Today is Sunday, Today is Monday, Today is Tuesday, Today is Wednesday, Today is Thursday, Today is Friday, Today is Saturday
|
Today is unknown!
]
                                    
1:
2:
3:
4:
5:
6:
7:
8:

Select allOpen in new window



Passing Data from a Form

One common reason to use server-side programming on sites is to collect data from the visitors. To collect some data from the user we will use a simple HTML Form:

<html>
<form method="post" action="process.wbsp">
First name: <input type="text" name="fname" size="30">
</br>
Date of birth: <input type="text" name="bdate" size="30">
<input type="submit">
</form>
</html>
                                    
1:
2:
3:
4:
5:
6:
7:
8:

Select allOpen in new window



Now on the server-side in our file "process.wbsp":

Hello $WBV[fname], your date of birth is $WBV[bdate]!
                                    
1:

Select allOpen in new window



Sending emails

A very powerful tool that is common on websites is a contact us form. The form can simply send an email by WhizBase, passing the subject, description and client's email.

First we have the HTML form:

<html>
<form method="post" action="email.wbsp">
Your email: <input type="text" name="email" size="30">
<br>
Subject: <input type="text" name="subject" size="30">
<br>
Body <textarea cols="30" rows="5" name="emailbody"></textarea>
<input type="submit">
</form>
</html>
                                    
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window



Now we make the WhizBase email:

[FormFields]
wb_command=P
wb_mailserver=out.mail.com
wb_to=info@mydomain.com
wb_subject=$wbv{subject}
wb_from=$wbv{email}
<!--WB_BeginTemplate-->
<html><body>
$wbv[emailbody]
</body></html>
                                    
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window



By defining the data of the server in the code before, we have code which will send an email to the defined destination.

Working with the Database

The simplest DB that WhizBase work with is Microsoft Access "mdb". But it also work with any common database.

To query all the fields in an access recordset we use this code:

[FormFields]
WB_Command=q
WB_Basename=biblio.mdb
WB_Rcdset=titles
WB_TempName=$default$
                                    
1:
2:
3:
4:
5:

Select allOpen in new window



This code will show all the data in the DB viewed in 20 records in a page with a navigator automatically generated for easier surfing.

Writing files

Finally, how to write files using WhizBase?
You have a lot of ways to write files in WhizBase, for example you can write ini files or txt files. I will show you the simplest way I have found:

[FormFields]
wb_destination=today_is.txt
wb_redirect=today_is.txt
<!--WB_BeginTemplate-->
Today is $WBFN[DATE]
                                    
1:
2:
3:
4:
5:

Select allOpen in new window



When you open this file you will find today's date.

What is next

WhizBase can do a lot more than my examples have shown; you can work with sessions, arrays, variables, make complex calculations, update/delete/add records in any DB, sending sms's or mails to mailing lists and other features.

You also also wish to read some of my previous articles:
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Uploading-files-to-your-webpage-in-WhizBase.html
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-database-driven-website-in-3-steps.html
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Simple-form-validation-with-WBSP.html
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-Password-Strength-Meter-in-WhizBase.html
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Creating-a-small-address-book-application-in-WhizBase.html
http://www.experts-exchange.com/articles/Programming/Languages/Scripting/Creating-live-visitors-counter-who-is-online-in-WhizBase.html

NurAzije is a PHP and WhizBase programmer, who at the time of article publication is working in partnership with WhizBase on several projects.

For more information email me at: NurAzije [at] Gmail [dot] com
Or visit the WhizBase official site at www.whizbase.com
Asked On
2010-03-03 at 05:55:13ID2597
Tags

WhizBase

,

DB

,

database driven website

,

CMS

Topic

Scripting Languages

Views
972

Comments

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Scripting Languages Experts

  1. mplungjan

    145,789

    Master

    0 points yesterday

    Profile
    Rank: Savant
  2. Ray_Paseur

    91,292

    Master

    0 points yesterday

    Profile
    Rank: Savant
  3. billprew

    63,376

    Master

    0 points yesterday

    Profile
    Rank: Genius
  4. RobSampson

    54,636

    Master

    0 points yesterday

    Profile
    Rank: Genius
  5. DaveBaldwin

    51,700

    Master

    2,000 points yesterday

    Profile
    Rank: Genius
  6. sedgwick

    43,950

    1,600 points yesterday

    Profile
    Rank: Genius
  7. leakim971

    43,184

    0 points yesterday

    Profile
    Rank: Genius
  8. dgofman

    36,400

    0 points yesterday

    Profile
    Rank: Genius
  9. COBOLdinosaur

    28,424

    0 points yesterday

    Profile
    Rank: Genius
  10. woolmilkporc

    24,200

    0 points yesterday

    Profile
    Rank: Genius
  11. ozo

    20,600

    0 points yesterday

    Profile
    Rank: Savant
  12. Qlemo

    19,984

    2,000 points yesterday

    Profile
    Rank: Genius
  13. chaituu

    19,100

    0 points yesterday

    Profile
    Rank: Sage
  14. tagit

    19,000

    0 points yesterday

    Profile
    Rank: Genius
  15. farzanj

    18,550

    0 points yesterday

    Profile
    Rank: Genius
  16. nap0leon

    15,094

    0 points yesterday

    Profile
    Rank: Sage
  17. paultomasi

    14,700

    0 points yesterday

    Profile
    Rank: Master
  18. StingRaY

    13,136

    0 points yesterday

    Profile
    Rank: Wizard
  19. jason1178

    13,044

    0 points yesterday

    Profile
    Rank: Genius
  20. HainKurt

    12,350

    0 points yesterday

    Profile
    Rank: Genius
  21. HonorGod

    11,600

    0 points yesterday

    Profile
    Rank: Genius
  22. ahoffmann

    11,136

    0 points yesterday

    Profile
    Rank: Genius
  23. basicinstinct

    10,800

    0 points yesterday

    Profile
    Rank: Genius
  24. leew

    10,030

    0 points yesterday

    Profile
    Rank: Savant
  25. ChrisStanyon

    9,864

    0 points yesterday

    Profile
    Rank: Sage

Hall Of Fame