Gossamer Forum
Home : General : Perl Programming :

how do i write code so a user can input text...like their age and i can output it again

Quote Reply
how do i write code so a user can input text...like their age and i can output it again
i have looked around websites, using goole and altavista...but i cant find how to get a user to input their age, name, height, etc...whatever i want them to input...and then print something like


print "your name is (whatever the code is like $name)";



if you understand me at all please help me
Quote Reply
Re: [skateboarder83] how do i write code so a user can input text...like their age and i can output it again In reply to
Pretty simple.

Code:
#!/usr/bin/perl

# using 'strict' means you have to define all your
# variables with 'my'..see variable examples further
# down. Once they have been defined in that sub
# routine, there is no need to redefine them.
use strict;

# use CGI.pm, rather than loads of
# long winded crap to get the variables...
use CGI;
$IN = new CGI;

# grab the variables passed over...
my $name = $IN->param('name');
my $age = $IN->param('age');

# print the content type header, and then the text
# you want. ' and " (as well as a few other
# charachters) need to be escaped by putting a
# backslash in front of them....just so you know why
# I have backslashes in my code ;)
print $IN->header();
print "Your name is $name, and your age is $age....arn't you an old 'en then ;)";

Hopefully that helps Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Feb 17, 2003, 1:59 AM
Quote Reply
Re: [Andy] how do i write code so a user can input text...like their age and i can output it again In reply to
Quote:
# you want. ' and " (as well as a few other # charachters) need to be escaped by putting a # backslash in front of them....just so you know why # I have backslashes in my code ;)


Err no they don't. Only " need to be escaped.

Last edited by:

Paul: Feb 17, 2003, 2:00 AM
Quote Reply
Re: [Paul] how do i write code so a user can input text...like their age and i can output it again In reply to
LOL...whoops. I was trying to make a point about escaping '," $ etc....must have got carried away Laugh

Thanks for pointing that out....

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates