May 25, 2011

Sending an email with embedded images using WhizBase

WhizBase has a built-in functions for sending a rich-text (HTML) emails. In your email you can easily include

How to collect data from web visitors and save them in your database

It is very easy to make data collecting web application using the WhizBase. We will do it using only two WBSP files - one containing the form (form.htm) and the other that saves received data into the database (add.wbsp).

Database structure for subscribers.mdb
Table Mlist
FistName Text 50
LastName Text 50
Email    Text 50


File form.htm
<html>
<head>
<title>Subscribe to mailing list</title>
</head>
<body>
<form action="add.wbsp" method="POST">
<table border="1" cellspacing="0"" cellpadding="3" bordercolor="#000000" bgcolor="#FFFFFF" style="border-collapse:collapse;">
<tr><td valign="top"><strong>First Name</strong></td><td valign="top"><input type="text" name="WBF_FirstName" value=""></td></tr>
<tr><td valign="top"><strong>Last Name</strong></td><td valign="top"><input type="text" name="WBF_LastName" value=""></td></tr>
<tr><td valign="top"><strong>Email Address</strong></td><td valign="top"><input type="text" name="WBF_email" value=""></td></tr>

</table>

<input type='submit' value='Submit'> <input type='reset' value='Reset'>
</form>
</body>
</html>


File add.wbsp
<!--
[FormFields]
WB_BaseName=subscribers.mdb
WB_Command=A
WB_RcdSet=mlist
-->
<!--WB_BeginTemplate-->
<html>
<head>
<title>Thank you for subscribing</title>
</head>
<body>
Thank you for subscribing with us!<br>
Added data:<br>
$wbf[FirstName] $wbf[LastName], $wbf[email]
</body>
</html>

As you can see, first file is ordinary HTML file with form, text input fields and submit/reset buttons. Second file is a simple WhizBase program that instruct WhizBase to use the table mlist from database file subscribers.mdb, to add data received in WBF_ form fields and to display added data using $wbf function.

May 18, 2011

Whiz your database to the web, now as a SaaS!

DSD WhizBase has released version 6.1 of WhizBase, a powerful tool primarily focused on publishing databases on the web with little or no programming knowledge.

WhizBase is the friendly middleman between your database, where you keep your data, and the web, where you need it to be!
It does the talking between the two, so you can make the most out of your time and resources! It enriches your HTML with powerful yet extremely easy to use dynamic features, such as: merging your pages with database contents, uploading files, password protecting files, adding, updating and deleting database records, conditional statements, loops, math functions, and more than 200 other functions.

So whenever you need to get content from a database to the web, or from the web into a database, WhizBase is the fastest and most effective solution!
Even if you have no programming experience whatsoever, with minimal HTML and excel sheet skills, you will see results in less than 30 minutes!
And if you're an IT professional, WhizBase can truly shine for you because it allows you to bridge platforms, technologies, and doesn't require picking up whole new language skill sets! WhizBase is a great platform for building professional web based applications, SaaS, intranet solutions and any other kind of dynamic web content.

WhizBase supports all database types, including: Access 2.0 to 2010, dBASE III, IV and 5.0, Paradox 3.x, 4.x and 5.x, FoxPro 2.0, 2.5, 2.6 and 3.0, MS Excel files, TXT and CSV files, MySQL, MS SQL, Oracle, Firebird, Informix, etc.
Output is exportable to RTF, XML, HTML, DHTML, TXT, RSS, JavaScript, CSS, VB Script, WML, Adobe® FLASH® external data file, XHTML, XAML, WAP and more.

New version brings numerous enhancements including the support for virtual directories, tools for stronger administration of hosted sites, native support for Microsoft® Access 2010 databases and many new functions and system variables.

With this version WhizBase is offered also as a SaaS, so instead of buying the license you can simply rent it for only $15/month, along with your choice of offered hosting plans (price varies), or integrate WhizBase service with your own existing hosting plans for only $20/month.

WhizBase 6 runs under Windows 95 / 98 / NT4 / 2000 / Me / XP / 2003 / Vista / 2008 /Windows7 and supports many popular Windows-based web servers that support standard CGI applications and filtering including IIS, Apache, Xitami, Abyss, and many others.

A 14 day risk-free all-inclusive trial of WhizBase software solution combined with hosting services is available free of charge, and you can also download a fully functional trial version of WhizBase 6.1 from http://www.whizbase.com/.

WhizBase 6.1 costs $299 (US) for a single-domain license. Server and Developer licenses are available. For more information, contact Becky R. Northaven, 803 E. 1st Street, Port Angeles, WA 98362; Skype: BeckyNorthaven; Email: info@whizbase.com Internet: http://www.whizbase.com/ Phone: +1 (360) 775-2844.

Mar 30, 2011

Create an AJAX supported registration form with WhizBase

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles on WhizBase).

The Structure

I will first explain the structure of our registration form, as I am using AJAX, I will not have any refresh for our page, so I will have one main page with the HTML and JS code.
For the validation process I will use one WhizBase file, for submitting registration data I will use another WhizBase file.
To store the registration information I will need a DB, and for this demonstration I will use the simplest one, Microsoft Access DB.
Every registration process needs a confirmation process to reduce spam registrations. So I will need one WhizBase file for confirmation, for sending the email I will use two files (I will explain why later in this article).
Now let give names, I will create default.wbsp, validate.wbsp, submit.wbsp, mail.wbsp, blank.html and confirm.wbsp. I will create reg.mdb for DB.

Registration Elements

The registration form will contain a user name, first name, last name, email and password. All elements are required, so no element must be empty. The user name must be available, the password must be repeated to confirm the password and the email must be real.
<html>
<head>
<title>Registration Form</title>
<script type="text/javascript">
function loadXMLDoc(url,rezult)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById(rezult).innerHTML=xmlhttp.responseText;
}
function Validate()
{
loadXMLDoc('validate.wbsp?username='+document.getElementById("username").value+'&fname='+document.getElementById("fname").value+'&lname='+document.getElementById("lname").value+'&password='+document.getElementById("password").value+'&password2='+document.getElementById("password2").value+'&email='+document.getElementById("email").value,'msgs');
if(document.getElementById('msgs').innerHTML==""){
loadXMLDoc('submit.wbsp?wbf_username='+document.getElementById("username").value+'&wbf_fname='+document.getElementById("fname").value+'&wbf_lname='+document.getElementById("lname").value+'&wbf_password='+document.getElementById("password").value+'&wbf_email='+document.getElementById("email").value,'msgs');
}
}
</script>
</head>
<body>
<div id="msgs"></div>
<fieldset><legend>Enter your information in the form below.</legend><br />
Username:<br />
<input type="text" name="username" id="username" size="40" maxlength="60" /><br /><br />
First Name:<br/>
<input type="text" name="fname" id="fname" size="40" maxlength="60" /><br /><br />
Last Name:<br/>
<input type="text" name="lname" id="lname" size="40" maxlength="60"/><br /><br />
Password:<br />
<input type="password" name="password" id="password" size="40" maxlength="60"/><br /><br />
Confirm Your Password:<br />
<input type="password" name="password2" id="password2" size="40" maxlength="60"/><br /><br />
E-Mail:<br />
<input type="text" name="email" id="email" size="40" maxlength="60"/><br /><br /> </fieldset>
<div align="center">
<input type="button" value="Submit" onclick="Validate();" /></div>
</body>
</html>
Let me now explain the HTML and JS code. The HTML code have the basic elements of the registration, I have input text fields to insert data needed for the registration with two password fields (for the password, and a second for confirmation). Finally I have a submit button and a div for viewing system messages.
The JS code has two functions, the first is the AJAX JS function, the other is the validate function that I call when I submit the form.
You will notice I call AJAX for two reasons, one is for validating the data in the form, the second is for saving the data in the DB.

Validation process

I will create a file for validating form data and will name it as "validate.wbsp". In this script I need to validate data, if there is errors I must display an error message, if not, keep the output empty. The output will be returned by AJAX and displayed in the messages div.
[FormFields]
wb_basename=reg.mdb
wb_rcdset=profile
WB_Command=Q
wb_query=username="$wbv{username}"
wb_maxrec=1
[MsgAndLbl]
WBM_NoMatch=$wbsetv{msg|}
<!--WB_BeginTemplate-->$wbif["$wbp[rc]"=1|$wbsetv[msg|The username is not available, plase choose another!<br />]|]$wbif["$wbv[username]"=""|$wbsetv[msg|$wbgetv[msg]Please write your username!<br />]|]$wbif["$wbv[fname]"=""|$wbsetv[msg|$wbgetv[msg]Please write your first name!<br />]|]$wbif["$wbv[lname]"=""|$wbsetv[msg|$wbgetv[msg]Please write your first name!<br />]|]$wbsplit[$wbv[email]|email_array|@|F]$wbsplit[$wbgetv[email_array(1)]|domain|.|F]$wbif["$wbv[password]"=""|$wbsetv[msg|$wbgetv[msg]Please insert a password!<br />]|]$wbif["$wbv[password]"<>"$wbv[password2]"|$wbsetv[msg|$wbgetv[msg]Your passwords do not match!<br />]|]$wbif[($wbcstr[$wbv[email]|@]=1) and ($wblen[$wbgetv[email_array(0)]]>0) and ($wblen[$wbgetv[email_array(1)]]>0) and ($wblen[$wbgetv[domain(0)]]>0) and (($wblen[$wbgetv[domain(1)]]>1) and ($wblen[$wbgetv[domain(1)]]<5))||$wbsetv[msg|$wbgetv[msg]Please insert a valid email address<br />]]$wbgetv[msg]
WhizBase do not recognize lines, it's code is directly embeded in HTML, so any extra white space or break will show in the HTML, so I have removed all white spaces and breaks I do not need.
Let us go through the code step by step.
[FormFields]
wb_basename=reg.mdb
wb_rcdset=profile
WB_Command=Q
wb_query=username="$wbv{username}"
wb_maxrec=1
[MsgAndLbl]
WBM_NoMatch=$wbsetv{msg|}
<!--WB_BeginTemplate-->
Here I am connecting to my DB Access file with the record set (table) profile, making a Query command and giving a where clause option username="$wbv{username}", where $wbv{username} will show the parameter I sent by AJAX by get or post method. For WhizBase get and post are the same.
I am limiting the records with 1 maximum, because I just want to check if the username already exists in the DB. If there is no records I will set the msg variable empty, I will need this variable later in the code. WBM_NoMatch gives "No Matching records" message by default, I do not want that, so I am just setting a variable.
$wbif["$wbp[rc]"=1|$wbsetv[msg|The username is not available, please choose another!<br />]|]
If the query above returns data I will give an error message that the username is not available, and save the message in the msg variable. I'm using an IF statement and check if $wbp[rc] which returns the number of records are equal to one.
$wbif["$wbv[username]"=""|$wbsetv[msg|$wbgetv[msg]Please write your username!<br />]|]
In case the username is empty I give an error message to write the username. When I assign the message to the variable I must not forget the messages we have from before, so I use wbgetv in wbsetv to add the past ones also.
$wbif["$wbv[fname]"=""|$wbsetv[msg|$wbgetv[msg]Please write your first name!<br />]|]
$wbif["$wbv[lname]"=""|$wbsetv[msg|$wbgetv[msg]Please write your first name!<br />]|]
$wbif["$wbv[password]"=""|$wbsetv[msg|$wbgetv[msg]Please insert a password!<br />]|]
The same process as before I do for the first name, the last name and the password.
$wbif["$wbv[password]"<>"$wbv[password2]"|$wbsetv[msg|$wbgetv[msg]Your passwords do not match!<br />]|]
If the passwords do not match, it is also an error. WhizBase uses <> for not equal. If you put != it will provoke a syntax error.
$wbsplit[$wbv[email]|email_array|@|F]
$wbsplit[$wbgetv[email_array(1)]|domain|.|F]
$wbif[($wbcstr[$wbv[email]|@]=1) and ($wblen[$wbgetv[email_array(0)]]>0) and ($wblen[$wbgetv[email_array(1)]]>0) and ($wblen[$wbgetv[domain(0)]]>0) and (($wblen[$wbgetv[domain(1)]]>1) and ($wblen[$wbgetv[domain(1)]]<5))||$wbsetv[msg|$wbgetv[msg]Please insert a valid email address<br />]]
Checking the email if it is valid is a little more complicated process: I need to check if the email address has an @ sign, and if it has at least one character before and after the @ sign. I also check if the domain name part before the dot has at least one character, and if the TLD part is at least 2 characters but not more than four.
$wbgetv[msg]
Finally I display the error messages I have collected, if no error messages are provoked I will have an empty variable. This data is displayed by AJAX in my messages div.

The Database

Before I go with the submitting data process, I need to show you the DB I have created. It is one DB containing one table called profile. Profile contains seven fields. The id is an auto-incremental field. The confirm field is a number type field with zero default value. The rest fields (username, fname, lname, password, email) are text type fields. I am saving the DB as "reg.mdb" access file.

Submitting the data

The submitting section of the code doesn't just save data to the DB, it also calls the email file to send a confirmation request email.
Before I get to that, I pass the parameters in the URL using JS, a little bit different than before. I am use a wbf_ prefix for every parameter I want to add to the DB. WhizBase takes them automatically and filters them, then adds them in the location we specify.
[FormFields]
wb_basename=reg.mdb
wb_rcdset=profile
WB_Command=A
<!--WB_BeginTemplate-->$wbgeturl[mail.wbsp?id=$wbf[id]&email=$wbf[email]]You will recieve a confirmation email to finish the registration process.
This code will save the data in reg.mdb DB, in profile table using Add command. I will use wbgeturl function to call the email sending file, I am passing the id and the email of the last inserted data. By $wbf I can get the data inserted by this operation.
I return via AJAX the message "You will receive a confirmation email to finish the registration process.".
At this time I have data in the DB, but it is still not confirmed. I have created a confirm field in the DB which has by default a zero value.

Sending email

Sending an email in WhizBase is very easy, it supports HTML by default, anything I write in this file after the "<!--WB_BeginTemplate-->" code, will be shown in the email. So I must be careful what I write.
[FormFields]
WB_Command=P
WB_From=admin@yourdomain.com
WB_Redirect=blank.html
WB_Subject=Please confirm your registration
wb_mailserver=mail.yourdomain.com
WB_To=$wbv{email}
<!--WB_BeginTemplate-->Please click <a href="http://www.yourdomain.com/confirm.wbsp?wbf_id=$wbv[id]">here</a> to confirm your registration.
The command P is for sending custom email. I specify the email address I am sending from, as well as from which mail server, the recipient's email address, and the subject of the email. After the "<!--WB_BeginTemplate-->" code I write everything I want to show in the email, which in this case is a link to the confirmation page, with the id of the profile I saved.
I call this file with the wbgeturl function, which will show me the data returned from the file called. So I need to return nothing by redirecting the page I am calling to blank.html (which is a blank file). The redirect in WhizBase is made on the server side, so I do not get the message of the email, but the blank page.

Confirmation process

When the guest makes a registration he will receive my email for confirmation, the link to the confirmation must be clicked, which will call my file for confirmation.
[FormFields]
wb_basename=reg.mdb
wb_rcdset=profile
WB_Command=U
WB_UID=id
WB_FORCED=wbf_confirm=1
<!--WB_BeginTemplate-->Now you can login to the system!
The confirmation will update the DB, and put value 1 in the field confirm for the specified profile. Updating the DB is simple, I specify the DB name, the recordset (table) name, the U command for update, I specify which field is the unique identifier for this process. In our case it is ID. And I will force one parameter as it is sent with the URL call, it is wbf_confirm = 1.
Finally I tell the guest that he has become a user. In the next article I will show you how to make a Login in WhizBase code.
For more information email me at: NurAzije [at] Gmail [dot] com Or visit the WhizBase official site at www.whizbase.com

Mar 23, 2011

Whizbase fast tutorial

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]
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]
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
]
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]
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!
]

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>
Now on the server-side in our file "process.wbsp":
Hello $WBV[fname], your date of birth is $WBV[bdate]!

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>
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>
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$
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]
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.
For more information email me at: NurAzije [at] Gmail [dot] com Or visit WhizBase official site at www.whizbase.com

Mar 21, 2011

Creating live visitors counter (who is online) in WhizBase

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase.
In this article I assume you have read my previous articles and know some WhizBase basics, as how to query, insert or update a DB.

We will need one table in the DB where we will keep the data of the recent visitors. The principle goes like this:

1- the visitor enters the site
2- we check the IP address of visitor and check if he is in the DB
3- if the IP exists, we update its record with current time
4- if not, we insert a new record
5- To include to visitor in our counting he must check-in in last 5 seconds

The database table used by the tutorial

I will not go through the SQL or the Access file creation, I will just describe what we need in the DB. We will need one table named "visitor". It will have the following fields:
Id as integer(9) autoincrement primary key
IP as char(100) unique and not null
Lastvisit as DateTime
I will create it in access DB and name the file visitor.mdb, and the table as visitor.
The id is auto increment field, so we will not need it in our code, it is just for table indexing and maintenance. The IP is the IP address of the visitor, and it must be unique and not null. Lastvisit will be a date and time of the last visit.

If exists include update, else include add

As we stated in the introduction, we will need to check if the visitor is online or not, and then include the file which makes the needed changes on the DB.
[FormFields]
WB_BaseName=visitor.mdb
WB_RcdSet=visitor
WB_Query=IP=$WBE{REMOTE_ADDR}
WB_Command=Q
<!--WB_BeginTemplate-->
$WBIF[$WBP[RC]>0|
$WBGETURL[update.wbsp?wbf_id=$WBF[id]]
|
$WBGETURL[add.wbsp?wbf_ip=$WBE[REMOTE_ADDR]]
]
<html>
<head>Number of visitors online</head>
<body>
$wbsr[show.sr]
</body>
</html>
In this code we have started WhizBase file and queried the DB «visitor.mdb», the table «visitor» where the IP address is gained by «$wbe[remote_addr]». «$wbe» is the function for reading operating system environment variable, in this case variable remote_addr that exist in every web server. I have named this file as «onvisitors.wbsp».
Now using «$wbif» we check if count of records is greater than zero by «$wbp[rc]>0», and if true we call the file «update.wbsp» and pass the parameter wbf_id with the id of current record. If false («$wbp[rc]=0») we call the file «add.wbsp» and pass the WBF_IP value.
Finally we call a sub-report file which will give us the result of how many users are online using «$wbsr» function.

I have visited your site before, update me

This is a description of the file that will be used to update the DB and record the time of last visit.
[FormFields]
WB_BaseName=visitor.mdb
WB_RcdSet=visitor
WB_Command=U
WB_UID=ID
WB_FORCED=wbf_lastvisit=$WBFN{FDT(yyyy-mm-dd hh:mm:ss)}
<!--WB_Begintemplate-->
This is a simple update script, we connect to «visitor.mdb», open table «visitor» and make an update to the unique field id and force one more parameter named «wbf_lastvisit» with the current date and time in the suitable format.
In previous paragraph we've explained why we call this file and give it wbf_id as a parameter, and you know WhizBase needs a unique field to update the record by. So we defined field "id" as the unique one. Then we needed the current time, so we have forced one more parameter (same as if we have sent it by form, but for security reasons we've used this method). The parameter is wbf_lastvisit which has the value of current date and time formatted in full year-month-day hour:minutes:seconds format.
Since we need no feedback from this file, it will do the update and return an empty string (a blank page).

This is my first visit to your site, insert me

We use this simple code to call the file «insert.wbsp» and pass the parameter with the IP of the visitor.
[FormFields]
WB_BaseName=visitor.mdb
WB_RcdSet=visitor
WB_Command=A
WB_FORCED=wbf_lastvisit=$WBFN{FDT(yyyy-mm-dd hh:mm:ss)}
<!--WB_Begintemplate-->
There is no need to describe anything in this code, it is the same as previous one but for addition (wb_command=A).

So how many visitors are on my site now?

Finally, we will look into the file «show.sr» which we include as a sub-report in our WBSP file.
[FormFields]
WB_BaseName=visitor.mdb
WB_RcdSet=visitor
WB_Query=lastvisit>$WBDCALC{$WBFN{FDT(yyyy-mm-dd hh:nn:ss)}|10|s|-}
WB_Command=Q
<!--WB_Begintemplate-->
<html>
<head>
<title>Number of users</title>
</head>
<body>
There is $WBP[RC] users now online!
</body>
</html>
In our sub-report we make a query to the DB «visitor.mdb» on table «visitor» and get all records where the last visit is greater than current time minus ten seconds. This will return all IPs that where recorded for the last ten seconds.
$wbdcalc makes arithmetic operations on dates, so we pass the current date and time and number of intervals to be added to or subtracted from it. We use «s» for interval (as seconds) and defined 10 of them, and finally we defined subtraction using the minus operator.
We will show just the number of visitors that are currently online, but not their IPs, so we need only «$wbp[rc]» which we have described before in this article.

What's next

That is how we record/count/show the number of visitors in the last 10 seconds using the WhizBase. Now, you can call «onvisitors.wbsp» with AJAX every 5-8 seconds from any page on your site and you'll have 100% real data and will not depend on the refresh of the page.
For more information email me at: NurAzije [at] Gmail [dot] com Or visit WhizBase official site at www.whizbase.com

Mar 17, 2011

You just finished building the perfect database for use as a web-app, if only you knew how to write a web-app
What do you do?

Well, writing a web application does not have to be complicated and definitely does not have to take months of programming. With WhizBase it takes just two steps to make your database "airborne".

Step one - create report that will display records from your database
Open your ordinary, plain HTML web page, position your cursor where you want
your records displayed and type the following code (replace values for
WB_BaseName and WB_RcdSet with your own values):

#*
[FormFields]
wb_basename=biblio.mdb
wb_rcdset=(Authors inner join titles on authors.au_id=titles.au_id) inner join
publishers on publishers.pubid=titles.pubid
wb_command=q
*#
#*Now we will add some plain HTML with no WhizBase code*#
<table border="1" cellpadding="3" cellspacing="0">
<tr>
<td>Title</td>
<td>Year published</td>
<td>ISBN</td>
<td>Author</td>
<td>Publisher</td>
</tr>
#*And here we will start adding some really simple WhizBase code*#
<!--WB_BeginDetail-->#*Define the beginning of block that will be repeated for every record*#
<tr>

<td>$wbf[Title]</td>
<td>$wbf[Year published]</td>
<td>$wbf[ISBN]</td>
#*Since we have field "Name" in two joined tables we must add table name in $WBF function together with the name of the field*#
<td>$wbf[Authors.name]</td>
<td>$wbf[Publishers.name]</td>
</tr>
<!--WB_EndDetail-->#*Define the end of repeating block *#
</table>
$wbnavigator[]

Save it as books.wbsp and the report is finished.

Step two - create search form

The search form for this example will be ordinary page with HTML form as follows:

<form action="books.wbsp" method="POST">
<table border="1" cellpadding="3" cellspacing="0">
<tr>
<td>Title</td>
<td><input type="text" name="WBF_Title" value=""></td>
</tr>
<tr>
<td>Year Published</td>
<td><input type="text" name="WBF_Year Published" value=""></td>
</tr>
<tr>
<td>ISBN</td>
<td><input type="text" name="WBF_ISBN" value=""></td>
</tr>
<tr>
<td>Search conditions</td>
<td ><select size='1' name='wb_andor'>
<option value='And'>all conditions</option>
<option value='Or'>any condition</option>
</select></td>
</tr>
</table>
<input type='submit' value='Search'>
<input type='reset' value='Reset'>
</form>

As you can see, there's nothing special with this form except that we named input text fields same as database fields with prefix (WBF_). When user submits the form data to books.wbsp (report we created earlier) WhizBase opens database biblio.mdb, create recordset based upon WB_RcdSet value combined with WHERE clause generated from form fields WBF_Title, WBF_Year published, WBF_ISBN. Upon creating recordset, WhizBase "reads" the report, search for detail section (everything between <!--WB_BeginDetail--> and <!--WB_EndDetail-->), finds the keywords (in this case $wbf[] functions) processes them and send to the browser, and repeats it for 20 records. After that, it process $WBNavigator[] function and generate links to other report pages (paginate the report).
Of course, you can format HTML form and WhizBase report anyway you want using ordinary HTML or CSS.

More info: http://www.whizbase.com/

Mar 7, 2011

You just created your client’s website, now he wants a database.
What do you do?

Well, if you are a hardcore programmer/web developer, there’s a plenty of choices. You can use ASP, PHP, ASP.NET, Ruby on Rails, Python, Perl, Java, etc. However, if you are just a humble web designer primary focused on making beautiful, eye-catching, state-of-the-art graphic layouts, and with development knowledge that’s just about enough to make a decent web page that shows well on all browsers and have a good SEO, then the choice is not that big. Of course, you still can select between few options:

Option A - Tell your client you can’t do it.
Never, never select this option. If you have to do it, don’t do it!

Option B - Hire a programmer/web developer to do it for you
This appears to be a good solution, but there are few serious issues with it – you will take your client’s request and pass it to the developer, then it will turn out that you did not get it right and you need to modify the request, then the developer will ask for more money because of extra work, then it goes in circle until the project is finally finished, and you have spent almost a half of project budget on outsourcing. But that’s not the end – if something goes wrong – who do you think your client is going to call – your outsourcing developer? Don’t think so – he will call you and he will demand immediate answers and reactions. I do not need to explain any further – you got the picture.

Option C - Do it yourself
Always the best solution, that allows you to control all parts of the web site you created, but you are not a developer, so how the heck I can suggest it. Well, this is how:
A) Collect your client’s data in an Excel spreadsheet, or Access database, or simple comma-delimited text file (CSV)
B) Add some simple, yet powerful, magic with WhizBase
C) Upload files to the web server and your database is ready to go.

Creating a small address book application in WhizBase

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses.
I will use a MS Access DB (.mdb file), but you can apply this tutorial for any DB you want, there is no significant difference, and the concept is the same.
We will make one default page which will show us all the records sorted alphabetically, then two files for update, one for delete and two for addition.

Creating the DB

I will not go through the SQL or the Access file creation, I will just describe what we need in the DB. We will need one table named contacts . It will have the following fields:
Id as integer(9) autoincreament primary key
Firstname as char(255)
Lastname as char(255)
Tel as char(255)
InsertionDate as DateTime
Whatever DB type you use, you will need these fields, so create the table and let s begin. I have created my contacts.mdb access DB file.

General file «default.wbsp»

This file will connect to the DB and select all the contacts sorted alphabetically by first name:
[FormFields]
WB_BaseName=contacts.mdb
WB_Command=Q
WB_RcdSet=contacts
WB_maxrec=20
WB_Order=Firstname
<!--WB_BeginTemplate-->
<html>
<head><title>Address Book</title></head>
<body>
<h1>Address Book</h1>
<table width='80%' border='0' cellpadding='5' cellspacing='0'>
<tr><th>ID</th><th>First Name</th><th>Last Name</th><th>Telephone</th><th>Insert Date</th><th colspan='2'>Action</th></tr>
<!--WB_BeginDetail-->
<tr><td>$wbf[id]</td><td>$wbf[Firstname]</td><td>$wbf[Lastname]</td><td>$wbf[Tel]</td><td>$wbf[InsertionDate]</td><td><a href='edit.wbsp?wbf_id=$wbf[id]'>Edit</a> <a href='delete.wbsp?wbf_id=$wbf[id]'>Delete</td></td></tr>
<!--WB_EndDetail-->
</table>
<a href='add.htm'>Add Contact</a>
</body>
</html>
In our first file we connect to the DB file contacts.mdb, which is located in the same folder as default.wbsp. In WhizBase we give instructions for DB connection at the beginning, so we first make [FormFields] section which is the start of the file header. We specify some parameters, WB_BaseName is the path of the DB, WB_Command will be Q as for Query. WB_maxrec will be 20 records, we want our address book to paginate the records in 20 rows each page. And WB_Order will be Firstname, because we want to sort the report alphabetically by Firstname.
<!--WB_BeginTemplate--> will mark the end of the file header. We now make the design of our address book. <!--WB_BeginDetail--> and <!--WB_EndDetail--> are used to loop through the query results. WhizBase brings you the data automatically, so you do not need to assign any variables or arrays. You need just to put the data placeholders in the code.
$wbf[fieldname] is the placeholder, as the system loops through the query result, for each row we take the value of the field name we want to show, in our case we are showing the id, firstname, lastname, tel and insertiondate.
We made three links, one for edit, another two for delete and add commands. Take a look at the edit and delete links, you will see that we are giving a wbf_id parameter. We will need that later.

Adding records Form «add.wbsp»

To add records we need a plain HTML form, so we will not use any WhizBase in this file, but take a look at the input names.
<html>
<head><title>Add contact</title></head>
<body>
<h1>Adding Contact</h1>
<form action='addc.wbsp' method='post'>
Frstname : <input type='text' name='wbf_firstname' value='' /><br />
Lastname : <input type='text' name='wbf_lastname' value='' /><br />
Telephone : <input type='text' name='wbf_tel' value='' /><br />
<input type='submit' value='Add' />
</form>
</body>
</html>
WhizBase picks up all parameters sent by POST or GET method and put them in one server array. Some parameters have a special meaning for WhizBase, any parameter beginning with wbf_ will be treated as a DB entry, it uses these parameters as values for comparison for Query and Delete commands (WHERE clause in SELECT statement), and as values to be entered into the table for Update and Add commands. This simplifies working with DB's, no need to write complex and long queries, WhizBase makes it automatically.
As we want to add 3 information in the DB - firstname, lastname and telephone, we use three parameters wbf_firstname, wbf_lastname and wbf_tel as inputs. Fields ID and insertiondate will be added automatically.
Save this file as add.htm, and let's move to file addc.wbsp that does all the adding work.

Adding records «addc.wbsp»

Every server side scripting language can receive inputs from visitors and process data from the DB. That makes them better than client side scripting languages. WhizBase as a server side scripting language also receive inputs, and processes them.
In add.htm we collected 3 parameters from visitor and sent them using post method. All the data we want to add to database have wbf_ prefix in the name, so WhizBase will process and filter them automatically. Let us look at this code and see how WhizBase make an insert to the DB:
[FormFields] WB_BaseName=contacts.mdb
WB_RcdSet=contacts
WB_Command=A
WB_FORCED=wbf_InsertionDate=$WBFN{DATE}
<!--WB_Begintemplate-->
<html>
<head>
<title>Adding Contact</title>
</head>
<body>
Contact have been added.<br />
<a href='default.wbsp'>View Addressbook</a> <a href='add.htm'>Add new contact</a>
</body>
</html>
In this file we have connected to the DB by wb_basename, selected the table contacts with wb_rcdset, and gave an addition command by setting wb_command = A where «A» stands for Addition.
WhizBase took the 3 parameters with prefix wbf_ and added them in the table automatically, but we have two more fields in the contacts table - «id» and «InsertionDate». The «id» is set in the table as autonumber so it will be set automatically, but «InsertionDate» we must add somehow, and we do not want visitor to change it. We could add it as a fourth parameter, but that would not be very safe, because visitors might find the ways to change it. So, since we want to add it on server-side safely, we use wb_forced variable, which will force any parameter we want (in this case wbf_InsertionDate) and ignore the value(s) sent by form. $wbfn{date} is used to pass the system date and time.

Deleting records «delete.wbsp»

Deleting records in WhizBase is very easy and secure, you cannot delete all records at once, and you cannot inject the query or hack it. And it is very similar to addition.
[FormFields]
WB_BaseName=contacts.mdb
WB_RcdSet=contacts
WB_Command=D
WB_UID=ID
WB_Redirect=default.wbsp
<!--WB_BeginTemplate-->
Do you remember the parameter we sent in the delete link, «wbf_id» we will need it now. To delete a record by id we need that id so we submit it automatically by wbf_id.
There are three new commands in this code, let go through them. «wb_command=d» is telling the server to execute delete command where «D» stands for delete. «wb_uid» is the command where we specify the name of the unique field (different value for every record) that we will use to prevent deletion of more than one record at the time. In our case it is field «ID», and without this, command delete is not safe enough. Finally «wb_redirect» is a simple redirect command where we tell the server to redirect visitor to the location we want. In our case we want the application to go back to the address book.

Edit a record Form «edit.wbsp»

When we want to edit a record we first need to show the values we have in the DB for specific record, so we can edit it and then save it. So, we have two steps with the DB here, the first is to select the record we want to edit from the DB, after editing it we need to save the changes in the DB.
[FormFields]
WB_BaseName=contacts.mdb
WB_Command=Q
WB_RcdSet=contacts
<!--WB_BeginTemplate-->
<html>
<head><title>Edit contact</title></head>
<body>
<h1>Edit Contact</h1>
<form action='editc.wbsp' method='post'>
Frstname : <input type='text' name='wbf_firstname' value='$wbf[firstname]' /><br />
Lastname : <input type='text' name='wbf_lastname' value='$wbf[lastname]' /><br />
Telephone : <input type='text' name='wbf_tel' value='$wbf[tel]' /><br />
<input type='hidden' name='wbf_id' value='$wbf[id]' />
<input type='submit' value='Save' />
</form>
</body>
</html>
This is very simple code, we talked about all its elements before, just notice that we did not use wb_maxrec because we always edit one record at the time, and we also did not use wb_order for the same reason.
For editing the record we will need to send its «id» so we use <input type='hidden' name='wbf_id' value='$wbf[id]' />.
WhizBase selected our record automatically by the id we provided in the link with wbf_id.

Save edited record «editc.wbsp»

The last file we will do in this article is editc.wbsp where we will save the record. In the previous file we have sent all needed parameters by POST with a prefix «wbf_».
[FormFields]
WB_BaseName=contacts.mdb
WB_RcdSet=contacts
WB_Command=U
WB_UID=ID
WB_Redirect=default.wbsp
<!--WB_Begintemplate-->
In this file we have just one new command «WB_Command=U» which tells the server to make an Update. Note that for Update command we must set the WB_UID.
With this we have finished our simple address book application in WhizBase. As you can see, in WhizBase it is very easy to work with the DB, and you do not need to know any SQL or make any queries.
To download the all files in this example please visit this link: http://www.ziddu.com/downloadlink/7482469/small_address.rar For more information email me at: NurAzije [at] Gmail [dot] com Or visit WhizBase official site at www.whizbase.com

Nov 19, 2009

Make a Password Strength Meter in WhizBase

Today the Internet is everywhere, we use it in everything, it is the buzz word of our time. When it first began it was just an experiment, a network for exchanging some data between universities, no one used it for exchanging private data.



Today it is 90% social powered network, everyone have a profile on some social website, a lot of people have money accounts on the net, some others have galleries and private data. So now we have to take care about security, how to secure our data, we need a good password, most people use «trustno1» or «000000» or their birth dates. That is not a good password, any cracking engine can guess that one.



Making a good password

A good password must have numbers, alphabetic characters (upper and lower case), other characters, they must be in a random order and must not mean anything. So do not use English words with meaning or some number combinations of something in your life.



A good example for a good password is ubXr-z9)7mn: we have upper and lower case letters, we have numbers and we have other characters. This password is nearly impossible to guess.



We will show you how to make password strength meter in WhizBase. The concept is easy, the user enters the password, we check it if it has all the 4 elements in it and give strength value back.



So let us start.



Give me your password

We will make a simple HTML form where we will ask the user to insert a username and a password. It is the standard form you can find everywhere on the net. Let us name it «index.htm»



<html>

<head><title>WhizBase Password Strength Meter</title></head>

<body>

<form action="'chpwd.wbsp'" method="'post'">

Username : <input type="'text'" name="'username'" value="''"><br />

Password : <input type="'password'" name="'pwd'" value="''"><br />

<input type="'submit'" value="'check">

</form>

</body>

</html>

Some notes about this code, we always use POST method in the form to hide our password when sending it through the web, we need the username to check if the password contains the username in it. We will create the file «chpwd.wbsp» which will make the checking for us.



Mambo Jumbo stuff of the code

Before we start we need to write down what we want to check and how we mark the password strength. I will make a list of things we need to check and every point have 1 point mark. So if the password passes 3 out of 6 it will have 50% strength.




  1. The length of the password must be at least 8 characters

  2. The password must not contain the username in it

  3. The password must contain numbers

  4. The password must contain special characters

  5. The password must contain lower case letters

  6. The password must contain upper case letters



Now lets begin with the code, save it in 'chpwd.wbsp':




$wbsetv[strength|0]

$wbif[$wblen[$wbv[pwd]]>7|$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]|]


$wbif[$WBCSTR[$wbv[pwd]|$wbv[username]|T]>0||$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]]


$wbsetv[avail|F]

$WBSPLIT[0,1,2,3,4,5,6,7,8,9|numbers|,]


$wbsetv[count|0]


$wbwhile[$wbgetv[count]<=$wbalen[numbers]|$wbif[$WBCSTR[$wbv[pwd]|$wbgetv[numbers($wbgetv[count])]|T]>0|$wbsetv[avail|T]|]$wbsetv[count|$wbcalc[$wbgetv[count]+1]]]


$wbif[$wbgetv[avail]="T"|$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]|]


$wbsetv[avail|F]

$WBSPLIT[!,#,$,%,&amp;,/,(,),=,?,*,@,;,:,-,_|schars|,]


$wbsetv[count|0]


$wbwhile[$wbgetv[count]<=$wbalen[schars]|$wbif[$WBCSTR[$wbv[pwd]|$wbgetv[schars($wbgetv[count])]|T]>0|$wbsetv[avail|T]|]$wbsetv[count|$wbcalc[$wbgetv[count]+1]]]


$wbif[$wbgetv[avail]="T"|$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]|]


$wbsetv[avail|F]

$WBSPLIT[q,w,e,r,t,z,u,i,o,p,a,s,d,f,g,h,j,k,l,y,x,c,v,b,n,m|scase|,]


$wbsetv[count|0]


$wbwhile[$wbgetv[count]<=$wbalen[scase]|$wbif[$WBCSTR[$wbv[pwd]|$wbgetv[scase($wbgetv[count])]|T]>0|$wbsetv[avail|T]|]$wbsetv[count|$wbcalc[$wbgetv[count]+1]]]


$wbif[$wbgetv[avail]="T"|$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]|]


$wbsetv[avail|F]

$WBSPLIT[Q,W,E,R,T,Z,U,I,O,P,A,S,D,F,G,H,J,K,L,Y,X,C,V,B,N,M|ucase|,]


$wbsetv[count|0]


$wbwhile[$wbgetv[count]<=$wbalen[ucase]|$wbif[$WBCSTR[$wbv[pwd]|$wbgetv[ucase($wbgetv[count])]|T]>0|$wbsetv[avail|T]|]$wbsetv[count|$wbcalc[$wbgetv[count]+1]]]


$wbif[$wbgetv[avail]="T"|$wbsetv[strength|$wbcalc[$wbgetv[strength]+1]]|]

Your password's strength is $wbcalc[$wbcalc[$wbgetv[strength]/6]*100]% $wbgetv[strength]




Let us speak English

Now let me explain what we have done. First we have created a variable which will contain the strength value, starting with zero because we assume the password is not good and then check every point and give a mark for success. We've done that with $wbsetv[strength|0] which means «WhizBase set a variable named strength with value 0».



Now we start with checking, first we check if the password length is more than 7 characters.





$wbif[

$wblen[$wbv[pwd]]>7

|

|

$wbsetv[strength|

$wbcalc[$wbgetv[strength]+1]

]

]


We say «If the length of 'pwd' variable greater is than 7 then add 1 point to the variable strength. Else do nothing.



Now we want to check if the password contains the username in it.
Again we use $WBIF «If number of occurences of the username variable in the pwd variable is greater than 0, then do nothing» (do not add a point), because there is at least one occurence and there should be none, «else add one point to the variable strength» because there is no user name in pwd.



Now we will make our script a little bit more complex, since we need to check if there are number characters in the password. To do so, we will define the numbers array and loop through the elements and check if any of them exists in the password string.




$wbsetv[avail|F]

$WBSPLIT[0,1,2,3,4,5,6,7,8,9|numbers|,]


$wbsetv[count|0]


$wbwhile[$wbgetv[count]<=$wbalen[numbers] | $wbif[$WBCSTR[$wbv[pwd]|$wbgetv[numbers($wbgetv[count])]|T]>0 |$wbsetv[avail |T]|]

$wbsetv[count|$wbcalc[$wbgetv[count]+1]]

]


$wbif[

$wbgetv[avail] = 'T'

|

$wbsetv[strength|

$wbcalc[$wbgetv[strength]+1]

]

|

]




At the beginning we suppose that there are no numbers, and give a value F as False for variable avail. Using wbsplit with the string «0,1,2,3,4,5,6,7,8,9» we make an array named numbers with the separator «,». This is a very cool way to create arrays in WhizBase. There are another ways but I prefer this one.



Now to loop through the array, we will need a counter so we will create a variable «count» with initial value of 0.



We will loop through the array while the condition (counter value <= length of the array) is true. In the loop we check with wbif function if there is an occurrence of the array element's value in the password string. If we find at least one we will set the variable avail as True «T». And off course we do not want our loop to go infinite, so we increase the value of the counter variable. After the loop is ended we check if our «avail» variable is True, which means that our password string has numbers in it, and add one point to «strength» variable (if true), else we do nothing. Now we repeat the same thing for special characters, lower case letters and upper case letters. I will not go through that code because it is the same as this one. Finally we will calculate the percentage of the strength, which is simple mathematical equation:






$wbcalc[$wbcalc[$wbgetv[strength]/6]*100]


We calculate the result of the strength points divided by maximum points (in our case it is 6), and then we multiply the result with 100 to get a percentage result.



And here we have a script that will tell us how powerful is our password.



For more information email me at: NurAzije [at] Gmail [dot] com
Or visit WhizBase official site at www.whizbase.com

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

Jun 9, 2009

Uploading files to your webpage

Have you ever wanted to upload your files to your hosting, or have you ever want to make a simple images gallery and let the visitors upload their pictures.



In this tutorial I will show you how simple is to write a script for uploading your files online with no need for complicated web scripts like ASP or PHP.



Simple HTML uploading form


If you want to upload images you will need a form, it is made in pure HTML, it is the page where you click on Browse and select the file you want to upload. Fortunately HTML provides us with the elements, we do not need to write scripts to list files on our computer.



<html>

<head>

<title>Upload an Image</title>

</head>

<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<form action="upload.wbsp" method="post" ENCTYPE="multipart/form-data">

Select file (*.jpg;*.gif - max. 100KB): <input type="file" name="image" size="20"> <input type="submit" name="sButt" value="Upload">

</form>

</body>

</html>


Let take a look in some important elements in this code, first the Form tag, without it our code will not work, the form tag must contain information like action (where to send the file data), method (there is two general methods – get and post, when sending files use post) and enctype(there is a lot of encoding types, multipart/form-data is used for uploading files).


Also we need to use the input of type file, that input is the one which let us browse our computer files. Last is the submit input, it is the button which people will click to send or upload the file.



Save this file as index.htm and put it in a folder so you do not loose it.



The butter of the work


Now we want to make the server-side file, it is the script which takes the file, save it on the hosting server.


[FormFields]

WB_AllowMultipart=T



[Upload]

WB_Disallow=![jpg,gif,png,bmp]

WB_UploadDir=/

WB_Overwrite=T

WB_MaxFSize=102400



<!--WB_BeginTemplate-->

<html>

<head>

<title&rt;File uploaded</title>

</head>

<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

Your file have been uploaded!

</body>

</html>


OK, do not get afraid, it is not complicated as it seems, I will explain every line before the HTML tag, make your self a coffee or a tea and sit down and read.



I will explain first what is used as a scripting language, it is WhizBase Server Pages, WhizBase is simple but powerful scripting language, it is made for non-programmers to simplify creating database-driven websites without the need for high experience in high-level programming languages.



Now in English, it is a scripting language for everyone, simple and easy for you to use. Let me show you how.



The header section


Every WBSP page have a header, it is a place where we put some information needed by the server, everything we write in this section will not appear in our page. This section contains the variables that are essential for processing WBSP file. Here you put information about the database, recordset, template, error template, log file, redirection, etc.



In the code we have [FormFields] which is a tag giving a notice for WhizBase engine to start interpreting the main commands of the WBSP file.



Then we have WB_AllowMultipart = T this variable controls if the current WBSP page will accept uploaded files (sent by client using multipart form). If this variable is set to TRUE WhizBase will accept and process uploaded files. This is a security measure so WBSP process the files sent to the write direction.



Second tag is [Upload] which is giving a notice for WBSP engine to start receiving information about the uploading process. Now ask your self, do you want viruses and a porn dialer on your server, if no you need to use WB_Disallow=![jpg,gif,png,bmp], we do not want users to upload any file, we only want images, so we disallow every file which does not have one of these extensions.



Where do you want to put your pictures, you need an upload directory, so we use WB_UploadDir=/, this variable defines the name of the directory on the server where WhizBase will save files uploaded using current WBSP file.



Do you want to overwrite your image? WB_Overwrite=T is a variable which defines if the file with same name that already exists on the server will be overwritten by newly uploaded file. We will use T as True. If you define it as F (False) WhizBase will generate a unique file name for the new one and save it like that.



If you do not want visitors to block your server, you need to limit their file's upload size, so you use WB_MaxFSize=102400 which is a variable which defines the maximum size (in bytes) of a single file that can be uploaded using current WBSP file. We have putted 102400 bytes.



Finally we put <!--WB_BeginTemplate--> to let the server know that now we are starting the body section, where we put our HTML code and what we want to show for visitors.



As you see, we can control everything when uploading files. And that how you simply make an upload form which works without the need of PHP or ASP.



For more information about WhizBase please visit WhizBase site

Jun 3, 2009

Make a database driven website in 3 steps

Today every company had to have a website, it is something like having a telephone number or a company address. A lot of companies do not have yet a budget for making a website, they think it is very expensive, and they are right. If you use a web developer in Europe you will need a couple of thousands of Euros to make a simple website to present your company.


In this article I will give a simple tutorial how to publish your database report without the need for a web-developer, something simple but yet very powerful, with your Microsoft access database.


This method is best way for web designers, who know how to make a web page in HTML, but do not know how to connect it with the database, without using PHP or ASP.


First step: create your report page


To show your report online, you will need a database access file and a HTML file which will show the report or the query results.


We will create the databse in Microsoft access, I will create a database and name it as biblio and create a table and name it Titles, we will make these fields:


  • ID as number data type which will be our primary key also.

  • Name as text data type

  • Publisher as text data type

  • PublishYear as text data type

I will fill it with some data and save it, and we have a database file.


If you have a design for your report you will need to slice it and make a HTML page, you can use GIMP on linux or Photoshop on windows, then use any HTML editor or text editor to make the HTML code.


I will use a simple example using WhizBase Server Pages (WBSP) to develop this report. WBSP is a very powerful tool for publishing databases online with a very simple code, it is not like classic web programing languages.


Create the header:


Every WBSP page have a header, it is a place where we put some information needed by the server, everything we write in this section will not apear in our page. This section contains the variables that are essential for processing WBSP file. Here you put information about the database, recordset, template, error template, log file, redirection, etc. We will simply say for the server to connect to our access database and select a table, list for example 10 records only and make a pagiation.



1 [FormFields]

2 wb_basename=biblio.mdb

3 wb_rcdset=Titles

4 WB_Command=Q

5 WB_MaxRec=10

6 <!--WB_BeginTemplate-->

[FormFields] is the starting tag for the section, when the server sees this code it will start receiving our commands. wb_basename=biblio.mdb is our database file, I have putted our database in the same folder as my HTML file so I am calling it directly. The server will look for the file name what ever we give as a path for it after wb_basename and connect to the database file. To specify which table we will select we use wb_rcdset=Titles, as you see I will select the table Titles. We told the server which database file to connect and which table to select, now we need to tell it what to do, and in our case is query, using the command WB_Command we give it a value Q and we did it. Finally we want to limit our results, let us show 10 records by page. We can skip this line and it will list the whole table, but what if we have a table with 10 000 records or more, do you really want to show it all in one page? So we will use WB_MaxRec=10 and that is all what we need. Now give the server a simple comment like command <!--WB_BeginTemplate--> which says to the server begin interpreting the template.


Create the body (template):


After creating the header setion we have to create the template, and that is very simple, it is our HTML code with simple lines of WBSP code where we want to show our data.



<html>

<head>

<title>Simple DB report page</title>

</head>

<body>

<table>

<tr><th>ID</th><th>Name</th><th>Publisher</th><th>Publish Year</th></tr>

<!--WB_BeginDetail-->

<tr><td>$wbf[ID]</td><td>$wbf[Name]</td><td>$wbf[Publisher]</td><td>$wbf[PublishYear]</td></tr>

<!--WB_EndDetail-->

</table>

<div align='center'>$wbnavigator</div>

</body>

</html>


In the template we want to view ten records in a table and then show the navigation bar where users can go next or previus page to see more records.


The most important code in this template is <!--WB_BeginDetail--> and <!--WB_EndDetail--> which represents the start and the end of the looping function, everything between these two will loop for as many times as records we want to show. If the query returned 10 records it will loop for ten times. Between these two commands we will show the records using the function $wbf[fieldname], in our case we are viewing four fields in the table and WBSP will replace every one with the field value in the table.



Finally we have $wbnavigator which will generate for us the navigation links automatically, this is a very cool command, we do not need to calculate anything, it will automatically create as many pages as we need.



We will save all this as defaut.wbsp file, where the extension wbsp will say to the server that this file have a WBSP code in it.



Second step: Create a search form


In the previous step we have made a report page, now we need a filtering form, for example what if we do not want to view all the records, we want to view just records for the publish year 2007.



Create a file named as «search.htm», in this file we will not need any WBSP code, we will only make a HTML form with inputs and a submit. We only must take into account one thing, how we will name our inputs, because WBSP have its automatic mechanism for catching get and post values.




<html>

<head>

<title>Search filter file</title>

</head>

<body>

<form action='default.wbsp' method='post'>

ID <input type='text' name='wbf_id' /><br />

Name <input type='text' name='wbf_name' /><br />

Publisher <input type='text' name='wbf_publisher' /><br />

Publish Year <input type='text' name='wbf_publishyear' /><br />

<input type='submit' value='submit' />

</form>

</body>

</html>



As you can see we have used a pure HTML, but we have also used a specific naming method in the input names. WBF_ID is WBF_ + ID where WBF_ is WhizBase prefix and ID is the name of the table field. WhizBase catches all the get and post data and filters them, then takes all the post and get data with prefix WBF_ and sends them to the query.



For example if we put a value 2000 in «Publisher Year» input, it will be a post value in the variable wbf_publisheryear, WhizBase will filter it and catch it because it has wbf_ prefix and then send it as a database query as «publisheryear = 2000».



Third Step: Upload everything online


Finally, we have a form file, a report file and a database. We do not need anything else. Now just upload the 3 files online in the same folder on a server which supports Whizbase or install Whizbase on your Windows server and put these files on the server and you will have a ready report and a filtering system.



For more information about WhizBase or to download it for free you can visit http://www.whizbase.com

Dec 28, 2008

Well here it is, after almost three years, we have finally published the new version. To be honest, it could have been released earlier, but we were constantly adding new features and prolonging the date of publishing final release, with usual “just to add this …” excuse.
However, the delay was useful, and we have added some really good features.

For those new to WhizBase - WhizBase is a web-authoring tool for building dynamic, database driven web content. Its main purpose is to build efficient, fast, easy-to-use Internet/intranet web applications, but it is also a great tool for fast and easy development of eye-catching, CMS-powered web presentations, with no programming skills.

WhizBase works with most Windows®-based web servers which support standard CGI applications and filtering, including IIS, Apache, Xitami, OmniHTTPd, Netscape Servers, Abyss Web Server, MicroWeb.
It is a hypertext pre-processor that can be used for the same purpose as PHP or ASP (or any other HTPP), and does not conflict with them (they can be installed on the same server).

The latest version (5.0) was officially published in December 2008. It may be used both as a scripting engine and as a CGI program. It has about 200 reserved words, and it supports almost any database type, still having the ability to create dynamic, eye-catching, database driven web content from the ordinary, static HTML documents with only a few WhizBase reserved words added.

The fact that WhizBase was developed by the experienced web developers, and not by the regular, hard-core programmers who know little (if anything) about the real-life problems web developers live with, separates WhizBase from other hypertext pre-processors and makes it more suitable for an average web developer.

To learn more about WhizBase or to download free trial please wisit our site at http://www.whizbase.com/