Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 28th, 2005, 6:27 PM   #1
aznluvsmc
Hobbyist Programmer
 
Join Date: Aug 2005
Posts: 137
Rep Power: 4 aznluvsmc is on a distinguished road
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 is offline   Reply With Quote
Old Oct 28th, 2005, 6:36 PM   #2
aznluvsmc
Hobbyist Programmer
 
Join Date: Aug 2005
Posts: 137
Rep Power: 4 aznluvsmc is on a distinguished road
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.
aznluvsmc is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:51 PM.

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