Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 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
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)
Reply With Quote
  #2 (permalink)  
Old December 4th, 2006, 09:02 AM
Friend of Wrox
Points: 7,425, Level: 36
Points: 7,425, Level: 36 Points: 7,425, Level: 36 Points: 7,425, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,524
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
Reply With Quote
  #3 (permalink)  
Old 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
Default

Hi,
Thank you for your code reply.

I am new to perl.
How to add these data into a database?
Reply With Quote
  #4 (permalink)  
Old December 4th, 2006, 09:55 AM
Friend of Wrox
Points: 7,425, Level: 36
Points: 7,425, Level: 36 Points: 7,425, Level: 36 Points: 7,425, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,524
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
Reply With Quote
  #5 (permalink)  
Old 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
Default

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

Reply With Quote
  #6 (permalink)  
Old 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
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?
Reply With Quote
  #7 (permalink)  
Old December 7th, 2006, 05:50 AM
Friend of Wrox
Points: 7,425, Level: 36
Points: 7,425, Level: 36 Points: 7,425, Level: 36 Points: 7,425, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,524
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 11:57 AM
perl jeet Perl 1 March 6th, 2006 04:06 PM
Beginning Perl toma All Other Wrox Books 6 August 10th, 2005 11:22 AM



All times are GMT -4. The time now is 03:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.