Jul 15, 2009

Version 5.0.13 released

WhizBase have released a new version of its engine today, including one new operator, operator modulus to $WBCALC function.

$WBCALC function gives the results of mathematical expressions. This make it easier in the code to distinguish between literally written 1+2 or mathematically waiting for a result.

For more information please visit WhizBase download page

PowerPack Wizards version 1.0.3 released

PowerPack is a User-friendly interface for WhizBase development. Using WhizBase PowerPack user can build all required files - WhizBase Query Form and WhizBase Report (WBSP file) without need to work directly with WhizBase Engine (using WhizBase parameters, tags and functions). Whole system is built to simplify and ease development of dynamic, database-driven web content. WhizBase Engine simplifies access to the database(s) on the web (either Internet or intranet) and WhizBase PowerPack makes configuring WhizBase easy and simple.

WhizBase Query Form Wizard will help you build web page that calls WBSP file. That is the page that has a HTML form which calls selected WBSP file(s) and sends the parameters entered by visitor and predefined by webmaster. Building this page is easy. It starts with opening database and record source (database table or query) and everything else is done by few mouse clicks following the program's instructions.

Final product of this procedure is source code of web page (HTML), which can easily be modified (or merged with ordinary HTML document) using any web-authoring tool.
Procedure for building Reports is exactly the same. WhizBase report (WBSP file) produced by wizard is a web page (in HTML format) that is used by WhizBase Engine to model the result of the action performed by visitor.

In the new release WhizBase team changed the default form action for quick search from $wbe[script_name] to $wbe[path_info]. Some web servers replace $wbe[script_name] with virtual path to wbsp.exe even when it is not running in CGI mode. $wbe[path_info] always returns path to WhizBase script (.wbsp) file.

Jul 7, 2009

Version 5.0.12 released

WhizBase have released a new version of its engine today, including one new variable and three functions.

WB_DBLock

This variable defines what type of record locking will be used when opening the recordset. If you are not sure what type of record locking you need do not change the default value which is (A) automatic. This function will solve the problem of database damages when more than one update occers in the same time. You can use pessimistic or optimistic, you can leave it automatic or use unspecified.

WBCSTR

A new function which returns a the count of instances of a string in another. This will help in easier string manipulations in cobination with other string manipulation functions WhizBase is getting a good collection of powerful functions.

WBESC

When transmitting data in URLs we have problems with URL encoding. This function will solve that problem, it will encode every value, and all can be returened back with its sister function WBUNESC.

WBUNESC

When transmitting data in URLs we have problems with URL encoded data. This function will decode any data encoded by WBESC, WBVC or WBFC functions.

For more information please visit WhizBase downlod page

Jul 2, 2009

Simple form validation with WBSP

Have you ever looked to the DB of your registered users, if you do you will find a lot of garbage data. Emails that does not exist, unreal names and comments with spam or empty fields.



In this tutorial I will show you how to make a simple validation form using WhizBase. With it you can not control and validate everything, but at least you will filter some data. It will learn you some basics and it will save you a lot of deleting work.



The boring part


The most boring part for a developer is HTML, generally programmers and developers do not like designing. If you ask me, I hate HTML coding, I mostly give it to my wife, she likes it and I work on the more complicated things «Server Side Scripting».

Let us make a file named as «form.htm» and put in it the next code:




<html>

<head>

<title>Feedback Form</title>

</head>

<body>

<form action="validation.wbsp" method="post">

<fieldset><legend>Enter your information in the form below.</legend><br />

First Name:<br/>

<input type="text" name="fname" size="20" maxlength="40" /><br /><br />

Last Name:<br/>

<input type="text" name="lname" size="40" maxlength="60"/><br /><br />

E-Mail:<br />

<input type="text" name="email" size="40" maxlength="60"/><br /><br />

Comments:<br />

<textarea name="comments" cols="40" rows="7"></textarea>

</fieldset>

<div align="center"><input type="reset" />

<input type="submit" name="submit" value="Submit" /></div>

</form>

</body>

</html>



Pay attention to the action attribute in the form tag, we will send our data to validation.wbsp which is our WhizBase Server Pages file.



The Need For Speed Part


Have you ever played Need For Speed, I like the Lamborghini car, that is a great game. WhizBase is something like that to other languages when you are developing a site. You do not need a lot of time to create it.



Let us create the file validation.wbsp and put WhizBase code in it:




[FormFields]
WB_Required=email,fname,lname,comments

<!--WB_BeginTemplate-->

<html>

<head>

<title>Validate Form</title>

</head>

<body>

$wbif[$wbcstr[$wbv[email]|@]>1|Please insert your email address<br />|]

$wbsplit[$wbv[email]|email_array|@]

$wbif[$wblen[$wbgetv[email_array(0)]]>0||Your have inserted an invalid email format<br />]

$wbif[$wblen[$wbgetv[email_array(1)]]>0||Your have inserted an invalid email format<br />]

$wbsplit[$wbgetv[email_array(1)]|domain|.]

$wbif[$wblen[$wbgetvdomain(0)]]>0||Your have inserted an invalid email format<br />]

$wbif[($wblen[$wbgetvdomain(1)]]>1) and ($wblen[$wbgetvdomain(1)]]<5)||Your have inserted an invalid email format<br />]

</body>

</html>



We need to check 4 values (email,fname,lname,comments) if they are empty or not, then in case if they are empty we will give an error. We simply use one command, it is WB_Required which will check all the fields required, if one of them are empty it gives an error.



[FormFields] is a command where we tell the server to start processing essential data for WhizBase file, and we close it with <!--WB_BeginTemplate--> command.



When we come to email validation we need to validate its format also, it is important if it is in the format of:

Charactars_and_Numbers@ Charactars_and_Numbers.4_to_2_Charactars_and_Numbers



From this we need to check:


  • does it have @ symbol, and only once.

  • Before @ symbol we need to have at least 1 character

  • Do we have a dot in the second part which we split with it the rest to two parts.

  • The first part must be at least one character

  • The second part must have at least 2 characters and at most 4




Let us start playing cards.

First we need to check if there is and only one @ symbol in the email, if it is false we give an error. This is done with if statement and wbcst function.



$wbif[$wbcstr[$wbv[email]|@]=1|| Please insert your email address<br />]


The IF:

$wbif[ CONDITION | IF TRUE | IF FALSE]




The CONDITION:

$wbcstr[ STRING | STRING TO LOOK FOR] = 1



In WhizBase get and post methods are considered the same, if you send a variable using post method or send it using get method all the variables are created on the fly as a special set.

Considering that we will just get these variables with $wbv[var_name].



The STRING:
$wbv[email]



Second we split the email address to two parts and put it in an array, then we check the first part if it is at least 1 character.



$wbsplit[$wbv[email]|email_array|@]

$wbif[$wblen[$wbgetv[email_array(0)]]>0||Your have inserted an invalid email format<br />]



We notice WBSPLIT function, it takes a string and an array name and a separator, creates the array and fill the string's part separated by the separator.



$wbsplit[ STRING | ARRAY_NAME | SEPARATOR]



In the second line we get the length of the first part by using WBLEN and check if it is more than zero characters.



$wblen[ STRING ]

To access a variable we need to use the WBGETV function which accesses variables and arrays, and we call the first part of the array with (0) - in WBSP 0 is the first element in the array.



The STRING:

$wbgetv[ VARIABLE_NAME ]



Third we make the same process to the other part with the dot, and we have a simple email validation done.



For more information email me at:
NurAzije [at] Gmail [dot] com

Or visit WhizBase official site at www.whizbase.com