Wrox Programmer Forums
|
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
 
Old December 4th, 2006, 08:29 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default perl

I want to create a interface which has add and delete button.
so how to pass a variable using perl? (in post method)
 
Old December 4th, 2006, 10:02 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 4th, 2006, 10:29 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thank you for your code reply.

I am new to perl.
How to add these data into a database?
 
Old December 4th, 2006, 10:55 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 5th, 2006, 12:57 PM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you help me, how to create a table using perl? (don't mean database table)

 
Old December 6th, 2006, 06:13 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old December 7th, 2006, 06:50 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting practical with perl ZORCH Perl 2 April 29th, 2007 10:00 PM
Perl help ZORCH Perl 3 April 25th, 2007 12:09 PM
Help with learning perl philrobeson Intro Programming 2 January 26th, 2007 12:57 PM
perl jeet Perl 1 March 6th, 2006 05:06 PM
Beginning Perl toma All Other Wrox Books 6 August 10th, 2005 11:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.