CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
form output to HTML

 



genestoy
Deleted

May 15, 2001, 6:45 AM

Post #1 of 4 (532 views)
form output to HTML Can't Post

   I have a form on my website that a user enters information in, when the "submit" button is clicked a cgi script is called and an email is sent to me. When I receive this info by email I would like it to be converted to HTML code so that I can just copy it into an existing webpage to update it. I am presently having to do it manually. The email comes to me like this:
city_name=phoenix
I would like it to come:
City Name: <FONT SIZE="3" COLOR="#211470">Phoenix</font>


The only thing that the user is inserting is the "phoenix" into the form on the website. And there are many more lines to the form that need to be converted also, but just trying to get an idea if this will be possible?
Thanks for any help
Gene




AICapone
Deleted

May 15, 2001, 9:08 AM

Post #2 of 4 (527 views)
Re: form output to HTML [In reply to] Can't Post

wait a second, what kind of forum is that? I mean you have to update the webpage?? Oh well, it's your problem but if you want email me and i'll explain you how to build forums.
But, so far what you can do is to send an email with line City Name: <FONT SIZE="3" COLOR="#211470">$yourinfo</font> where $yourinfo is anything you want (let it be Phoenix if you want). Of course $yourinfo comes from your form on the webpage



AlCapone

P.S. you need to put HTmL filtration on there



genestoy
Deleted

May 15, 2001, 1:19 PM

Post #3 of 4 (522 views)
Re: form output to HTML [In reply to] Can't Post

Al,
Sorry, didn't realize I was trying to build a forum. Thought this was about perl/cgi scripts.
Where does the line you gave go? On the form webpage? Anything with a space in it does not send, ie: City Name. It needs to be City_Name?
Thanks,
Gene



AICapone
Deleted

May 15, 2001, 2:14 PM

Post #4 of 4 (519 views)
Re: form output to HTML [In reply to] Can't Post

Well yeah...gotta admit I was wrong: you are not building forum. Probably I misread you post :))) anyway, I just kinda made some scetches for you little problem. You could try something like this:

#!/usr/bin/perl #####or wherever your perl
use CGI qw(param); ###join CGI modul

##########################
@body=param("body"); # taking
$subj=param("subj"); # parameters from
$from=param("from"); # some HTML form
$to=param("to"); # add passing to our .pl
$town=param("town i am from"); # your question about spaces
$mailprog='/usr/sbin/sendmail/'; # wherever your mail
###########################
###########################
$from=~s/@/\@/g; #changing @ to \@ so it won't
$to=~s/@/\@/g; #count as an array

foreach $lines (@body) { # if some one press enter
$lines =~ s/\n/
/g; # while entering test in <text
$lines =~ s/\n//g; } #area> it will count as new line
##########################
##########################
open (MAIL,"| $mailprog"); #open mail

print MAIL "To:$to\n"; # and print to:
print MAIL "Subject: $subj\n"; #subject:
print MAIL "From: $from\n"; #from

print MAIL "heyya how is it going bo?\n"; #some text
print MAIL "<font color=red>$town</font>\n"; #from
print MAIL "CYA laterzzz"; #us personally (optional)
print MAIL "@body"; #print whatever was in form
print MAIL "$town"; # specially for you :)))
close (MAIL); #n/c

print "Content-type: text/html\n\n"; #n/c

print <<HTML_GENERATING_FOR_FILE; # <<EOF

<html><body bgcolor="#f2f2f2">hello, i think we're done
don't you?
<p>the mail has been send to <b>$to</b> from <b>$from</b> with subject <b>$subj</b> and body <b>@body</b>

town <b>$town</b>
HTML_GENERATING_FOR_FILE

name this `mail.pl` and create mail.html with this in it:


<html><head><tilte></title></head>
<body bgcolor="#f2f2f2">
<FORM ACTION="mail.pl">
<table>
<tr><td>To:
<td><INPUT NAME="to" size=48>

<tr><td>From:<td><input name=from size=48>
<tr><td>Subj:<td><input name=subj size=48>
<tr><td>Town:<td><input name="town i am from" size=48>
<tr><td valign=top>Body:
<td><TEXTAREA NAME="body" ROWS=10 COLS=38 WRAP="VIRTUAL" ></TEXTAREA><p>
</table>
<INPUT TYPE="submit" value="Get this">
<input type="reset" value="clean up">
</FORM>
</html>


well that about does it. Though I did not check my mail I am pretty sure this will work, if you have any questions feel free to ask - you are more than welcome


AlCapone


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives