我想使用Perl腳本將數據填充到DBD數據庫中。如何使用perl腳本從URL向DBD數據庫插入表單數組?
這裏是我的html代碼:
<html>
</head>
<body>
<H1>Friend's contact book</H1>
<FORM ACTION="contact.pl" METHOD="POST">
<HR>
<H2>Friend's contact</H2>
<PRE>
Name:<INPUT TYPE="text" NAME="name">
Address:<INPUT TYPE="text" NAME="add">
</PRE>
</HR><P>
<INPUT TYPE="submit" VALUE="Sign Up"> or <INPUT TYPE="reset" VALUE="Cancel">
</P>
</FORM>
</body></html>
這裏是我的perl腳本: contact.pl
#!/usr/bin/perl
# Initialize DBI.
use DBI;
use strict;
# Make the database connection.
my $dbh = DBI->connect("dbi:Pg:dbname=friendcontact")
or die my $DBI::errstr;
# Store the SQL query
myy $stat = my $dbh->prepare("INSERT into friend (name, add) VALUE
(?,?)");
# Execute the query
my $stmh->execute();
# Tidy up
my $stmh->finish();
my $dbh->commit or die my $DBI::errstr;
我不能運行contact.pl代碼 它說「內部服務器錯誤「
有沒有anywa我可以糾正這個問題嗎?
非常感謝提前
謝謝 我已經編輯的代碼,就像你說的,但它是一種與 錯誤更新後: 內部服務器錯誤
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
Premature end of script headers: /home/friendcontact/private/cgi-bin/contact.pl
非常感謝 我已經編輯成有,但仍然有錯誤 – userpane