Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
|
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 November 2nd, 2006, 10:06 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 get the values of form field values

use CGI; $cgi = new CGI; if(!defined $newform->validate) { $submitted = $newform->submitted([ qw(title description type email interest dateposted)]); # set form field variable values in HERE }



is it possible to get the values of form field values that have been posted to this page?

how is it done?

Picco

www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old November 3rd, 2006, 05:32 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey crmpicco

You can just do (example to get the title field):

<code>
my $title = $cgi->param('title');
</code>

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com
 
Old March 16th, 2007, 10:57 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

hi, that worked a treat by the way charlie....forgot to write back....
here's my working script!!
Code:
#! /usr/bin/perl

# Craig R Morton
# Last_Edit: 08-Nov-2006

use CGI;
use ready::Sql;

$cgi = new CGI;
$sql = new ready::Sql;

$header = << 'STOP';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Edit Contact</title>
<link rel="stylesheet" type="text/css" href="/ssi/extranet.css">
<script src="/ssi/extranet.js" language="javascript"></script>
<script language="javascript">
<!--
function redirecttostart()
{
    window.location="craigtest.pl";
}
//-->
</script>
<script src="crmjs.js" language="javascript"></script>
<style type="text/css">
<!--
body {
    background-color: #ECECEC;
}
.table_contacts {
    width: 100%
    border: 2px;
    border-color: #000000;
    border-style: solid;
    font-family: Verdana;
    font-size: 11px;
}
-->
</style>
</head>
<body >
STOP

$footer = << 'STOP';
</body>
</html>
STOP

# Form field values passed from the previous page
$contactid = $cgi->param('hcontactid');
$name = $cgi->param('name');
$birthdate = $cgi->param('birthdate');
$email = $cgi->param('email');
$interest = $cgi->param('interest');
$telno = $cgi->param('telno');
$admin = $cgi->param('admin');

# if the admin 'yes' button has been checked then insert '1' into the DB otherwise insert '0'
if ($admin eq "yes") {
    $adminval = "1";
}
else {
    $adminval = "0";
}

# Update the DB with the values (name, birthdate, etc......) passed from the previous page
$sql->query(q{UPDATE `craigrm`.`contacts` SET name = (?), birthdate = (?), email = (?), interest = (?), telno = (?), admin = (?) WHERE contact_id = (?)}, $name, $birthdate, $email, $interest, $telno, $adminval, $contactid);

@getrecords = $sql->query(q{SELECT contact_id, name, birthdate, email, interest, telno, admin FROM `craigrm`.`contacts` ORDER BY contact_id ASC});

$content = "<table class='table_contacts' align='center'><tr><td>Contact ID</td><td>Name</td><td>Birthdate</td><td>Email</td><td>Interest</td><td>Tel No.</td><td>Admin</td></tr>";

while ($result = $getrecords[0]->fetchrow_hashref) {
    $dbcontactid = $result->{"contact_id"};
    $dbname = $result->{"name"};
    $dbbirthdate = $result->{"birthdate"};
    $dbemail = $result->{"email"};
    $dbinterest = $result->{"interest"};
    $dbtelno = $result->{"telno"};
    $dbadmin = $result->{"admin"};

    $content .= "<tr><td>$dbcontactid</td><td>$dbname</td><td>$dbbirthdate</td><td>$dbemail</td><td>$dbinterest</td><td>$dbtelno</td><td>$dbadmin</td></tr>";
}

$content .= "</table>";

print "Content-type: text/html\n\n";
print $header;

print "<div align='center'>";
    require "banner.pl";
    print "<br>Database Updated....";
print "</div>";

print $content;

=pod
print "Contact ID = $contactid<br>";
print "Name = $name<br>";
print "Birthdate = $birthdate<br>";
print "Email = $email<br>";
print "Interest = $interest<br>";
print "Tel No. = $telno<br>";
print "Admin = $admin<br>";
print "Adminval = $adminval<br>";
=cut

print "<div align='center'>";
    print "Back to Start";
print "</div>";
print $footer;
www.crmpicco.co.uk
www.ie7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to concatenate two values into one field haixia XSLT 3 November 7th, 2016 02:33 PM
Default Field Values tachtenberg Reporting Services 1 February 19th, 2008 05:52 PM
Multiple Values In One Field lefty4080 Access 1 December 12th, 2007 08:59 AM
Selecting on different values of the same field alphahamster SQL Language 4 May 30th, 2006 11:08 AM
Adding multiple form field values to database cdenequolo Classic ASP Basics 1 August 17th, 2004 05:38 PM





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