 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

December 4th, 2006, 08:29 AM
|
Registered User
|
|
Join Date: Dec 2006
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, 10:02 AM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
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, 10:29 AM
|
Registered User
|
|
Join Date: Dec 2006
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, 10:55 AM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
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, 12:57 PM
|
Registered User
|
|
Join Date: Dec 2006
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, 06:13 AM
|
Registered User
|
|
Join Date: Dec 2006
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, 06:50 AM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
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
|
|
 |