请教如何用delphi写留言版?(100分)

  • 主题发起人 softdelphi
  • 开始时间
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
请教如何用delphi写计数器,留言版,聊天室等程序?
 
J

Jams

Unregistered / Unconfirmed
GUEST, unregistred user!
计数器好办!--就是INC(访客),再写到文件里!
其他, >>
 
O

OopsWare

Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi -> File -> New -> Web Server Application
Delphi allows you to create Web server applications as CGI applications or dynamic-link libraries (DLLs). These Web server applications can contain any nonvisual component. Special components on the Internet palette page make it easy to create event handlers that are associated with a specific Uniform Resource Identifier (URI) and, when processing is complete, to programmatically construct HTMLdo
cuments and transfer them to the client.

 
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
我搞到一个计数器元代码(http://homepages.borland.com/aohlsson),但提示filename不对.而且也没有jpeg.pas? 希望高手搞定它告诉我,ok?
 

悲酥清风

Unregistered / Unconfirmed
GUEST, unregistred user!
jpeg.pas好像是Delphi自带的一个图像控件,是用来支持JPEG图像文件的.但需要你
自己添加到控件中.它的位置好像在delphi/bin下,你可以搜索一下.
 
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
搜索遍了找不到jpeg.pas
 

悲酥清风

Unregistered / Unconfirmed
GUEST, unregistred user!
jpeg.pas应该有的啊,不然你到delphi3目录下找找。要不你等几天,我毕业回家给
你到家里的机子找个发给你。
 
W

wjiachun

Unregistered / Unconfirmed
GUEST, unregistred user!
直接 uses jepg;
就可以啊,怎么会没有??
 
O

only you

Unregistered / Unconfirmed
GUEST, unregistred user!
呵呵,Borland只提供了Jpeg.dcu,没有Jpeg.pas.
该dcu在lib中。不过这跟本题有和关系
 
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
有谁用Delphi5写过留言板,计数器,聊天室吗?
 
C

CathyEagle

Unregistered / Unconfirmed
GUEST, unregistred user!
d3不支持jpeg.
 

程云

Unregistered / Unconfirmed
GUEST, unregistred user!
看看这可以吧。
unit Html;
interface
uses
Windows, Messages, SysUtils, Classes, HTTPApp;
type
TWebModule1 = class(TWebModule)
procedure WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest;
Response: TWebResponse;
var Handled: Boolean);
procedure WebModule1WebActionItem2Action(Sender: TObject;
Request: TWebRequest;
Response: TWebResponse;
var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
WebModule1: TWebModule1;

implementation
{$R *.DFM}
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest;
Response: TWebResponse;
var Handled: Boolean);
var html:string;
begin
html:='';
html:=html+'< html >< head >< title >会员注册< /title >< /head >< center >';
html:=html+'< H2 >会员注册< /H2 >< /center >';
html:=html+'< body background="" bgcolor="#fffff" >< td >< /td >';
html:=html+'< form action="webcgi.exe/Info" method="post" id="form1" name="form1" style="FONT-SIZE: larger" >';
html:=html+'< p >姓名:< input size="12" maxlength="10" name="UserName" >< /p >';
html:=html+'< p >性别:< input type="radio" name="Sex" value="Man" checked >男';
html:=html+'< input type="radio" name="Sex" value="Woman" >女< /p >';
html:=html+'< p >年龄:< input size="5" maxlength="3" name="Age" >< /p >' ;
html:=html+'< p >所在城市:< input size="20" maxlength="16" name="City" >< /p >' ;
html:=html+'< p >Email:< input size="24" maxlength="30" name="Email" >< /p >';
html:=html+'< p >留言:< textarea name="Textarea" rows="5" cols="30" >< /textarea >< /p >';
html:=html+'< center >< input type="submit" Name="submit" value=" 提 交 " >';
html:=html+'< input type="reset" value=" 取 消" >';
html:=html+'< /form >< /center >';
html:=html+'< /BODY >< /html >';
Response.Content :=html;
end;

procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
Request: TWebRequest;
Response: TWebResponse;
var Handled: Boolean);
var
html:string;
Output: TextFile;
Counts,line:integer;
begin

Assignfile(Output, 'List.Txt');{如果没有list.txt文件会报错,须先手工创建。}
Append(output);
for counts:=0 to Request.ContentFields.Count-2do
begin
if counts< Request.ContentFields.Count-2 then
begin
Write(Output, Request.ContentFields.Strings[counts]);
for line:=0 to 20-length(Request.ContentFields.Strings[counts]) do
begin
Write(Output,' ');
end;
end
else
begin
Write(Output, Request.ContentFields.Strings[counts]);
Writeln(Output,' ');
end ;
end;
CloseFile(output);
html:='';
html:=html+'< html >< head >< title >Thank You!< /title >< /head >< body >';
html:=html+'< center >< P >< H2 >'+Request.ContentFields.Values['UserName'];
html:=html+'您好!您已注册成功!< /H2 >< /P >';
html:=html+'< A href="http://zhou/scripts/Webcgi.exe" >点击这里返回< /A >';
html:=html+'< /center >< /body >< /html >';
Response.Content :=html;
end;

end.

 
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
陈云:
我借鉴了你的方法做出了一个简单的留言板(你的方法在delphi5下行不通)
但你把留言结果存为txt文本格式,怎样把它转化为html格式呢?或者更进一步做一个入口(象中文热讯的一样)?
 
S

softdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
程云,I'm sorry ,我把你的姓写成"陈"了!
 

程云

Unregistered / Unconfirmed
GUEST, unregistred user!
to softdelphi:
忘了作一下说明了。见下。
用DELPHI的CGI应用程序可以轻松的制作留言板主页。用ELPHI开发CGI应用程序不但可以实现ASP,HTML很难实现的低层操作,而且简化了CGI应用程序开发过程。
1.选择Delphi的菜单File|New,在New标签中选择“Web Server Application”。
然后在选择“CGI Stand-alone executable",创建一个CGI应用程序。
(如果想创建ISAPI或NSAPI应用程序,只需选择“ISAPI/NSAPI Dynamic Link Library”,后几步操作不变。)
2.系统自动创建一个非可视的WebModule1组件,我们按以下步骤给程序添加控制和代码:
(1)、双击WebModule1的Actions属性,弹出“Editing WebModule1.Actions”对话框;
(2)、单击Add按钮,添加一个新行WebActionItem1
(3)、单击WebActionItem1,在Object Inspector中将WebActionItem1的Default属性设置为True;这样设置使访问CGI.EXE时直接访问此页面。
(4)、单击Add按钮,添加一个新行WebActionItem2
(5)、单击WebActionItem2,在Object Inspector中将WebActionItem2的PathInfo属性设置为“/Info”;即访问此页面的路径为CGI.EXE/Info。
(6)、在Object Inspector中双击WebActionItem1的OnAction事件,添加代码。将留言板页面的HTML语句赋给Response.Content属性,使用户访问WEB服务器应用程序时显示。
(7)、在Object Inspector中双击WebActionItem2的OnAction事件,添加代码处理留言板页面传回的信息,同时显示相关信息通知用户。其中涉及Request.ContentFields.Values['index']及Request.ContentFields.Strings[counts]两个属性的应用。
Request.ContentFields.Values['UserName']是指留言板页面中name="UserName"的控件中的数据信息。
Request.ContentFields.Strings[Counts]是指留言板页面传过来各项数据及对应的控件名。以Counts区分其为哪项数据,其数值为留言板页面传输数据项的顺序号。
数据存储方式我采用文本文件存储,也可考虑改用数据库存储。

这下明白了吗?
 
Z

zeusangel

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢程云给我们大家的方法。
 
Z

zeusangel

Unregistered / Unconfirmed
GUEST, unregistred user!

"数据存储方式我采用文本文件存储,也可考虑改用数据库存储。 "
请问如何用数据库存储呢?请再次帮大家。谢谢你。
 
W

wjiachun

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
顶部