Welcome to the p2p.wrox.com Forums . You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
December 4th, 2006, 07:29 AM
Registered User
Join Date: Dec 2006
Location: london, , United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
perl
I want to create a interface which has add and delete button.
so how to pass a variable using perl? (in post method)
December 4th, 2006, 09:02 AM
Friend of Wrox
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,532
Thanks: 0
Thanked 0 Times in 0 Posts
html post form to 'xxx.pl' and put this in 'xxx.pl'
Code:
#! /usr/bin/perl
use CGI;
$cgi = new CGI;
my $name = $cgi->param('name');
print "NAME: $name";
www.crmpicco.co.uk
www.ie7.com
December 4th, 2006, 09:29 AM
Registered User
Join Date: Dec 2006
Location: london, , United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,
Thank you for your code reply.
I am new to perl.
How to add these data into a database?
December 4th, 2006, 09:55 AM
Friend of Wrox
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,532
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
#!/usr/bin/perl -w
use DBI;
$dbh = DBI->connect('dbi:mysql:perltest','root','password')
or die "Connection Error: $DBI::errstr\n";
$sql = "select * from samples";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
while (@row = $sth->fetchrow_array) {
print "@row\n";
}
www.crmpicco.co.uk
www.ie7.com
December 5th, 2006, 11:57 AM
Registered User
Join Date: Dec 2006
Location: london, , United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
can you help me, how to create a table using perl? (don't mean database table)
December 6th, 2006, 05:13 AM
Registered User
Join Date: Dec 2006
Location: london, , United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Please tell me, How to use perl script in a html file?
I wrote a html code. but I need to insert a perl script inside it.
How can I insert it?
December 7th, 2006, 05:50 AM
Friend of Wrox
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,532
Thanks: 0
Thanked 0 Times in 0 Posts
try this, and let me know how you get on:
Code:
#! /usr/bin/perl
# Craig R Morton
# Last_Edit: 07-Dec-2006
use CGI qw/:standard/;
my $cgi = new CGI;
# pass the forename, surname etc to the 'validateinput' subroutine
&validateinput( $cgi->param("forename"),
$cgi->param("surname"),
$cgi->param("************"),
$cgi->param("county"),
$cgi->param("town"),
$cgi->param("departmentname"),
$cgi->param("jobtitle"),
$cgi->param("dob"));
print "Content-type: text/html\n\n";
print <<ENDHTML;
<html>
<head>
<title>Adding HTML into a Perl Script</title>
<body>
<table>
<tr>
<td>Whatever in Hier</td>
</tr>
ENDHTML
if ($invalidinput eq "true") {
print "<tr>";
print "<td>You have an error in your form input, Go <span onClick='history.back();'>BACK</span></td>";
print "</tr>";
}
print <<ENDHTML;
</table>
</body>
</html>
ENDHTML
# FUNCTION: validateinput
# check the passed parameters to see if any are empty,
# if they are then set flag value
sub validateinput {
$sforename = $_[0];
$ssurname = $_[1];
$ssex = $_[2];
$scounty = $_[3];
$stown = $_[4];
$sdepartmentname = $_[5];
$sjobtitle = $_[6];
$sdob = $_[7];
if ( $sforename eq "" ||
$ssurname eq "" ||
$ssex eq "" ||
$scounty eq "" ||
$stown eq "" ||
$sdepartmentname eq "" ||
$sjobtitle eq "" ||
$sdob eq "") {
$invalidinput = "true";
} else {
$invalidinput = "false";
}
}
www.crmpicco.co.uk
www.ie7.com
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off