Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Perl (http://www.programmingforums.org/forum21.html)
-   -   Query String not being read (http://www.programmingforums.org/showthread.php?t=6696)

aznluvsmc Oct 28th, 2005 5:27 PM

Query String not being read
 
Hi,

I'm having a little trouble with a CGI script I'm making. The script doesn't seem to be reading the values in $ENV{'QUERY_STRING'} into my program.

Can someone tell me what I missed?

:

#!/usr/bin/perl

use warnings;
use strict;

my $error;

read(STDIN, my $qs, $ENV{'QUERY_STRING'});

my @pairs = split(/&/, $qs);
my %form;

foreach my $pair (@pairs) {
    my ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/(%[\dA-Fa-f] {2})/pack("C", hex($1))/eg;
    $form{$name} = $value;
}

print "Content-Type: text/html\n\n";

print <<HTML;
<? xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <link rel='stylesheet' href='~/ssrun/css/main.css' type='text/css' media='screen' />
    <title>INT322 Assignment</title>
</head>

<body>

<h1>Seneca Linux InstallFest Registration</h1>
<br />

<form method='GET' action=''>
    <b>Mutliple OS installation:</b>
    &nbsp; Yes <input type='radio' name='multi' value='y' />
    &nbsp; No <input type='radio' name='multi' value='y' />

    <br /><br /><b>OS to install:</b>
    &nbsp; Windows 95 <input type='checkbox' name='os' value='win95' />
    &nbsp; Windows 98 <input type='checkbox' name='os' value='win98' />
    &nbsp; Windows ME <input type='checkbox' name='os' value='winme' />
    &nbsp; Windows 2000 <input type='checkbox' name='os' value='win2000' />
    &nbsp; Windows XP <input type='checkbox' name='os' value='winxp' />
    &nbsp; Linux (Suse 9.1) <input type='checkbox' name='os' value='suse91' />
    &nbsp; Other <input type='checkbox' name='os' value='other' />

    <br /><br /><b>Clean install:</b>
    &nbsp; Yes <input type='radio' name='clean' value='y' />
    &nbsp; No <input type='radio' name='clean' value='y' />

    <br /><br /><b>Year PC was purchased:</b>
    &nbsp; <select name='year'>
        <option value='1998'>1998</option>
        <option value='1999'>1999</option>
        <option value='2000'>2000</option>
        <option value='2001'>2001</option>
        <option value='2002'>2002</option>
        <option value='2003'>2003</option>
        <option value='2004'>2004</option>
    </select>

    &nbsp; &nbsp; <b>Amount of memory in PC:</b>
    &nbsp; <select name='memory'>
        <option value='128'>128</option>
        <option value='192'>192</option>
        <option value='256'>256</option>
        <option value='384'>384</option>
        <option value='512'>512</option>
        <option value='gt512'>&gt;512</option>
    </select>

    &nbsp; &nbsp; <b>Amount of free space (GB):</b>
    &nbsp; <select name='space'>
        <option value='lt5'>&lt;5</option>
        <option value='10'>5-10</option>
        <option value='20'>10-20</option>
        <option value='gt20'>&gt;20</option>
    </select>

    <br /><br /><b>Student's name:</b>
    &nbsp; <input type='text' name='sname' maxlength='40' />

    &nbsp; &nbsp; <b>Email address:</b>
    &nbsp; <input type='text' name='email' maxlength='80' />

    <br /><br /><input type='reset' value='Clear' />
    <input type='submit' name='submit' value='Submit' />
</form>

</body>
</html>
HTML


aznluvsmc Oct 28th, 2005 5:36 PM

Please ignore this. After looking over some code examples, I realized I was mixing up how to read POST data and GET data. I've now taken out the read() line and just assigned the $ENV{'QUERY_STRING'} directly to a scalar.


All times are GMT -5. The time now is 2:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC