Whizbase快速教程

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可以做什么。 我希望您至少已经知道如何使用HTML,并且您了解Internet的基础知识以及Internet的工作方式。

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.

WhizBase是一种服务器端脚本语言,其命令使用简单的英语单词。 WhizBase文件通常具有.wbsp扩展名,但也不太可能具有.ic,.sr,.inc等文件。

The syntax of WhizBase is directly embedded in HTML code, for example if you want to show the current date you use:

WhizBase的语法直接嵌入HTML代码中,例如,如果您想显示使用的当前日期:

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.

首先解释每个WhizBase文件,然后将其发送回浏览器,因此该代码不会在页面的源代码中显示任何WhizBase代码。

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:

与大多数服务器端脚本语言一样,WhizBase支持条件编程,您可以在WhizBase中编写IF语句和切换大小写语句。 以下是基本语法和示例:

$WBIF[expression|true part|false part]

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

如果仅在星期五时需要显示字符串“ Today is Friday”,则使用:

$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:

如果仅IF和ELSE还不够(我们需要不止一种情况),则必须使用CASE语句:

$WBCASE[separator|value|conditionlist|resultlist|default]

For the seven days in the week:

在一周的7天中:

$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表单:

<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":

现在在服务器端的文件“ 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.

网站上常用的一种非常强大的工具是“与我们联系”表单。 该表格可以简单地通过WhizBase发送电子邮件,并传递主题,描述和客户的电子邮件。

First we have the HTML form:

首先,我们有HTML表单:

<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:

现在我们制作WhizBase电子邮件:

[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.

WhizBase使用的最简单的数据库是Microsoft Access“ mdb”。 但它也可以与任何通用数据库一起使用。

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.

此代码将显示页面中20条记录中查看的数据库中的所有数据,并自动生成一个导航器,以方便浏览。

Writing files

写文件

Finally, how to write files using WhizBase?

最后,如何使用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:

您可以通过多种方式在WhizBase中写入文件,例如,可以写入ini文件或txt文件。 我将向您展示我发现的最简单的方法:

[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.

WhizBase所能做的比我的例子所展示的还多。 您可以使用会话,数组,变量,进行复杂的计算,在任何数据库中更新/删除/添加记录,将短信或邮件发送到邮件列表和其他功能。

You also also wish to read some of my previous articles:

您还希望阅读我以前的一些文章:

https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Uploading-files-to-your-webpage-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Uploading-files-to-your-webpage-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-database-driven-website-in-3-steps.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-database-driven-website-in-3-steps.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Simple-form-validation-with-WBSP.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Simple-form-validation-with-WBSP.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-Password-Strength-Meter-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Make-a-Password-Strength-Meter-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Creating-a-small-address-book-application-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Creating-a-small-address-book-application-in-WhizBase.html https://www.experts-exchange.com/articles/Programming/Languages/Scripting/Creating-live-visitors-counter-who-is-online-in-WhizBase.html https://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

有关更多信息,请给我发送电子邮件:NurAzije [at] Gmail [dot] com

Or visit the WhizBase official site at www.whizbase.com

或访问WhizBase官方网站www.whizbase.com

翻译自: https://www.experts-exchange.com/articles/2597/Whizbase-fast-tutorial.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值