100+ |
Hi All,
How create OOP perl scripts and how to let users select different ouput html template to display the photo that they upload? Including the urls to refer to.
Kindly advise...
Cheers..
| |
Share:
Expert 2GB |
Your question is way to broad. If you don't know OO programming techniques yet that is where to start, with some OO tutorials or books. Perl comes with several OO tutorials, and a number of perl books discuss how to write OO programs with perl.
| | 100+ |
Your question is way to broad. If you don't know OO programming techniques yet that is where to start, with some OO tutorials or books. Perl comes with several OO tutorials, and a number of perl books discuss how to write OO programs with perl.
Hi Kevin,
Any reference sites which for beginners can start? thanks in advance. Cheers..
| | 100+ |
just want to be broadbased, but I will branch into uploading / downloading files, reading from db and inserting to db, website security, bandwidth optimization... ... Cheers...
| | Expert 2GB |
Perl comes with all sorts of tutorials. You can read them online or from your local install of perl. I recommend you buy the "Perl BookShelf Reference" on CD. For online resourses google is your friend. See also: http://bytes.com/forum/thread790489.html | | 100+ |
Hi Guru,
Thanks again! will go through.
Cheers..
Andrew
| | 100+ |
Hi All,
I tried the redirect, but it seemed that it did not work, the below script processes the username and password, and when the username and password is fine, then $test =1, but it just dont redirect to new webpage http://127.0.0.1/cgi-bin/cards2.pl
code that worked as plain redirect script
============================= -
use CGI;
-
my $query = new CGI;
-
-
-
my $url = "http://127.0.0.1/cgi-bin/cards2.pl";
-
print "ok";
-
print $query->redirect($url);
-
-
code that did not work
================ -
$sql = $dbh->prepare(qq{SELECT * FROM user_reg where user_name = "$user_name"});
-
$sql->execute();
-
-
while (my @data = $sql->fetchrow_array()){
-
-
if($data[0] eq $user_name and $data[1] eq $password)
-
{
-
-
-
-
# Print the date from the first four columns in the table
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "\t", $data[4], "\t",
-
-
$data[5], "<br>";
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "\t", $data[4], "\t",
-
-
$data[5], "\t", $data[6], "\t", $data[7], "\t", $data[8], "\t", $data[9], "\t", $data[10],
-
-
"\t", $data[11], "\t", $data[12], "\t", $data[13], "\t", $data[14], "\t", $data[15], "\t",
-
-
$data[16], "\t", $data[17], "<br>";
-
-
print "login is ok!";
-
-
my $test = 1;
-
-
-
-
}
-
-
else
-
-
{
-
print "not ok";
-
print "username : $user_name";
-
print "password : $password";
-
-
}
-
-
}
-
-
if($test = 1)
-
{
-
print "ok";
-
#my $url = "http://127.0.0.1/cgi-bin/cards2.pl";
-
-
-
# print $query->redirect($url);
-
-
print $query->redirect(-location=>'http://127.0.0.1/cgi-bin/cards2.pl',
-
-nph=>1,
-
-status=>301);
-
-
-
}
-
| | 100+ |
hi all,
The above code that did work, I got this in the webpage display
Thanks in advance,
Andrew
login is ok!okHTTP/1.1 301 Server: Apache/2.2.9 (Win32) Status: 301 Date: Fri, 26 Dec 2008 07:35:19 GMT Location: http://127.0.0.1/cgi-bin/cards2.pl 0
| | 100+ |
Hi All,
I found the answer, if the html form is printed, then the redirect cant work. The conditional if still there, the redirect can still work...
Cheers...
Andrew
| | Expert 2GB |
this line in your code is wrong:
if($test = 1)
it should be:
if($test == 1)
= assigns a value
== compares values
you also have:
my $test = 1;
but its inside a block of code making it "invisible" later in the script outside the block.
| | 100+ |
Hi Kevin / all,
Ok. noted thanks!
Btw 2 more queries...
1) $sql = $dbh->prepare(qq{SELECT * FROM user_reg where user_name = "$user_name"}); , do the equal here must be == also?
2) How to make the website's user authenticate and timeout after that...
Best Rgds,
Andrew
| | 100+ |
Hi Kevin / all,
The item 1) above i have to use = only i guess, tried eq and == cant work.
For item 2) i found the code below, but it cant really show the timeout, not sure what is the problem.
Error log : [Fri Dec 26 21:13:14 2008] [error] [client 127.0.0.1] script not found or unable to stat: D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/pngfix.htc
[Fri Dec 26 21:13:14 2008] [error] [client 127.0.0.1] File does not exist: D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/bv01011.gif, referer: http://127.0.0.1/cgi-bin/timeout30.pl
Access log : 127.0.0.1 - - [26/Dec/2008:21:13:14 -0800] "GET /cgi-bin/main3.pl HTTP/1.1" 200 6749 -
#!c:\perl\bin\perl.exe
-
#!/usr/bin/perl
-
-
# Note that if you do this, you must explicitly
-
# export everything you want to use:
-
use LWP::Simple qw($ua get);
-
-
$ua->timeout(30);
-
my $webpage = "http://127.0.0.1/cgi-bin/main3.pl";
-
-
-
print "Content-type: text/html\n\n";
-
my $html = get $webpage || die "Timed out!";
-
-
print "$html";
-
-
| | Expert 2GB | @happyse27 - SELECT * FROM user_reg where user_name = "$user_name"
The above is an sql query, its not perl code. As far as I know "=" is the correct syntax for the sql query.
I can't help with question #2.
| | 100+ |
Hi Kevin,
Np... Cheers... Thanks again.
Best Rgds,
Andrew
| | Expert Mod 2GB |
I have not done much (yet) with website authentication (for #2), but did a quick Google search and found a Perl Module for handling it using Apache.
I don't have any experience with the module but I figured I would throw it your way. Also, there seems to be a number of other possible links from the Google search for you to search through as well.
Happy Holidays!
Jeff
| | 100+ |
Hi Jeff,
Thanks and Happy Holiday... This module you recommended unfortunately not in activestate perl's listed module to test the webpage timeout / after login say 10 mins no user's web activity timeout. I found this link CGI::Session::Tutorial - Extended CGI::Session manual - search.cpan.org
But got apache error log :
[Mon Dec 29 02:41:30 2008] [error] [client 127.0.0.1] script not found or unable to stat: D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/cgi-session.pl
and access log error :
127.0.0.1 - - [29/Dec/2008:02:37:05 -0800] "GET /cgi-bin/cgi-session.pl HTTP/1.1" 404 220 -
#!c:/perl/bin/perl.exe
-
#!/usr/local/bin/perl
-
-
-
print "Content-type: text/html\n\n";
-
-
# Object initialization:
-
use CGI::Session;
-
$session = new CGI::Session() or die CGI::Session->errstr;;
-
-
$CGISESSID = $session->id();
-
-
#New
-
$cookie = $query->cookie( -name => $session->name,
-
-value => $session->id );
-
print $query->header( -cookie=>$cookie );
-
-
#new
-
CGI::Session->name("SID");
-
$session = new CGI::Session();
-
-
# send proper HTTP header with cookies:
-
print $session->header();
-
-
#New
-
printf ("<a href=http://127.0.0.1/cgi-bin/signin.pl">click me</a>", $session->name,
-
-
$session->id);
-
-
#New
-
$session = new CGI::Session( $sid );
-
$session = new CGI::Session( "serializer:freezethaw", $sid );
-
$session = new CGI::Session( "driver:mysql", $sid, {Handle=>$dbh} );
-
-
#New
-
$cgi = new CGI::Simple();
-
$session = new CGI::Session ( $cgi );
-
$session = new CGI::Session( "driver:db_file;serializer:storable", $cgi);
-
# etc
-
-
#New
-
my $name = $cgi->param('username');
-
$session->param('username', $name);
-
-
#New
-
$session->save_param();
-
-
# storing data in the session
-
##$session->param('f_name', 'Sherzod');
-
# or
-
##$session->param(-name=>'l_name', -value=>'Ruzmetov');
-
-
# flush the data from memory to the storage driver at least before your
-
# program finishes since auto-flushing can be unreliable
-
$session->flush();
-
-
#New
-
$name = $session->param("name");
-
printf "<input type=\"text\" name=\"name\" value=\"%s\" />", $name;
-
-
#New
-
@fruits = @{ $session->param('fruits') };
-
-
#New
-
$session->load_param($cgi, ["fruits"]);
-
-
#New
-
print $cgi->checkbox_group(fruits=>['apple', 'banana', 'apricot']);
-
-
#New
-
$template = new HTML::Template(filename=>"some.tmpl", associate=>$session);
-
print $template->output();
-
-
#NEw
-
Hello <a href="mailto:<TMPL_VAR email>"> <TMPL_VAR first_name> </a>!
-
-
#New
-
$session->clear(["~logged-in", "email"]);
-
-
#New
-
$email = $session->param("email");
-
-
# retrieving data
-
##my $f_name = $session->param('f_name');
-
# or
-
##my $l_name = $session->param(-name=>'l_name');
-
-
# clearing a certain session parameter
-
##$session->clear(["l_name", "f_name"]);
-
-
# expire '_is_logged_in' flag after 10 idle minutes:
-
##$session->expire('is_logged_in', '+10m')
-
-
# expire the session itself after 1 idle hour
-
$session->expire('+1h');
-
-
# delete the session for good
-
$session->delete();
-
-
| | 100+ |
kindly give me some pointers... cheers...
| | Expert Mod 2GB | @happyse27
First, patience. They are a virtue. This is the holiday season and most of us probably have plans for the holiday season and answers may not come as quick as you may expect.
Second, If Apache is complaining that it cannot find the script then you need to troubleshoot that. You are on Windows, so it isn't the same as Unix, so bear with me.
You need to find out where the cgi-bin directory that you are supposed to put your scripts in is located. This will be in your httpd.conf file, the apache configuration file.
That is where I would suggest you start. Windows is a funky beast to try and get LAMP working on.
Regards,
Jeff
| | 100+ |
Hi Sir,
Thanks. I was not rushing anyone, I forgot to ask question although I presented the case, so I posted a second post to ask the questions for pointers. I had realized that this site needs some time to respond as some of the experts and moderators are not online sometimes... Cheers...
Btw, what is LAMP? Cheers...
Best Rgds,
Andrew
| | Expert Mod 2GB | @happyse27
LAMP stands for Linux Apache Mysql PHP/Perl/Python. Its your basic web development environment. Its easy to get it going and running on unix, but on Windows, it tends to be a bit more of a pain. There are prebuilt installations of it for Windows that somewhat simplify it, you just have to search google for something like "lamp on windows".
Regards,
Jeff
| | 100+ |
Hi All,
1) What are the perl module that can easily interface with smtp server?
2) And for web hosting company, do they usually provide free smtp that can send and receive unlimited emails or even sms as we would buy a domain package with them... need help as I could not find free smtp server in the web to test my perl email program...
3) Any suggestion?? Cheers...
4) I cant post new posting again :|
Kindly assist on the above.
Cheers...
Andrew
| | Expert Mod 2GB |
Andrew,
You really need to read your private messages (see the inbox link at the top of your page) and respond to me accordingly!
Regards,
Jeff
| | 100+ |
hi sirs,
I did respond from my private email to forum support email saying that this website somehow due to bugs does not allow me to post new postings... that's why i added here.. But these are perl related issue for smtp and other things above which I REALLY need help. Please kindly assist.
Thanks in advance!
Andrew
| | Expert Mod 2GB | @happyse27
I don't want to do this in the thread, but you seem to not want to read the messages I have sent to your inbox here on bytes.com (again, please click on the "inbox" link at the top of the page to see the messages I have sent you).
1. You need to regularly check for messages in your inbox. That is how we contact you outside of these threads. The last message I sent (a while ago), I requested that you message me back to let me know that you read and understand it. You have not done so and that is not good. There is a formal warning in there you need to read.
2. You keep saying that you aren't able to post new threads, yet I seem to see threads started by you on January 9th and January 17th. From what I can tell, you are definitely able to post new threads and need to abide by the rules of this site!
Although you say the issues are related to your issue, the questions and the way you asked them were specific to the other topics where I moved the posts and started their new threads. If it is specifically a Perl issue, fine, but when you are trying to run a Perl program and something else isn't cooperating, like Apache and you then ask an Apache specific question, that is the problem. Do you see and understand?
Now, please go read your messages that I have sent you and reply.
Regards,
Jeff
| | Expert 2GB |
Modules you can look into:
Net::POP3
Net::SMTP
| | 100+ |
Hi Sirs,
Thanks... You can check your source codes or get more users to feedback, some days I can post, HOWEVER some days I cant(which I pasted the GUI to show you in some of my postings)... And I cant easily find the new post icon in the website(but this is not the main problem as I really cant post new post as the website did not allow me in the permission grant.)
And one more bug is when I logged in, it will not allow me to go forum and inform that I have login in already.
Hi Kevin,
Thanks. But does the 2 modules allow me to test to send emails to myself or other users as I understand it needs public smtp server to do the job...
Cheers...
Andrew
| | 100+ |
btw, I did reply emails previously three to four different times, not sure why your email account not receive. Please check your logs...
I swear I did all the above, I will try to separate the topics, but please kindly be understanding towards the problems with bytes website that I am facing, if I am not allowed to post as the permission rights got problem, then what is the way or procedure to allow me to post again. Let's work on these... Cheers...
| | 100+ |
btw, one more thing, your website did allow me to key in private message reply regardless of any moments, And the posting of my replies to you also didnt work. I wish I had the means to check which posting I reply...
Cheers...
| | 100+ |
Hi Kevin,
I could not find net::smtp in perl package manager, but the below codes worked fine, is it the same effect? I guess I have to use gmail account to test my smtp problem as they provide free smtp server.
Cheers..
Andrew -
-
#!c:/perl/bin/perl.exe -w
-
-
use strict;
-
use warnings;
-
-
use Mail::Sender::Easy qw(email);
-
-
print "Content-type: text/plain\n\n";
-
-
-
email({
-
'from' => 'EMAIL REMOVED FOR YOUR PROTECTION',
-
'to' => 'EMAIL REMOVED FOR YOUR PROTECTION',
-
'cc' => 'IP REMOVED FOR YOUR PROTECTION',
-
'subject' => 'Perl is great!',
-
'priority' => 2, # 1-5 high to low
-
'confirm' => 'delivery, reading',
-
'smtp' =>',
-
'port' => 25,
-
#'auth' => 'LOGIN',
-
'authid' => 'andrew',
-
'authpwd' => 'PASSWORD REMOVED FOR YOUR PROTECTION',
-
'_text' => 'Hello *World5* :)',
-
'_html' => 'Hello <b>World</b> <img src="cid:smile1" />',
-
'_attachments' => {
-
'smiley.gif' => {
-
'_disptype' => 'GIF Image',
-
'_inline' => 'smile1',
-
'description' => 'Smiley',
-
'ctype' => 'image/gif',
-
'file' => 'D:/program files/Apache Software
-
-
Foundation/Apache2.2/htdocs\smiley.gif',
-
},
-
#'mydata.pdf' => {
-
#'description' => 'Data Sheet',
-
#'ctype' => 'application/pdf',
-
#'msg' => $pdf_guts,
-
#},
-
},
-
}) or die "email() failed: $@";
-
-
| | Expert Mod 2GB |
Andrew,
I have now edited your most recent post for the following reasons:
1. You had multiple real world email addresses in the post. Emails are not allowed for your protection.
2. You had a password in the posting.
3. You had an IP address in the post. (albeit a local, non-internet accessible address, but an IP none the less).
You REALLY need to think about your security when you post. These forums are publicly searchable and any information here is scrapable.
Here is a link to our Posting Guidelines. If you haven't read them, please do. I doubt you have, otherwise you would be more abiding by them when posting.
Now that you have the link to them, you need to follow them.
| | Expert Mod 2GB |
Since a solution has been reached, I am closing this thread.
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
2 posts
views
Thread by Sandman |
last post: by
|
42 posts
views
Thread by Fred Ma |
last post: by
|
1 post
views
Thread by sm00thcrimnl13 |
last post: by
|
1 post
views
Thread by Al Belden |
last post: by
|
1 post
views
Thread by Jay Warmack |
last post: by
|
12 posts
views
Thread by rurpy@yahoo.com |
last post: by
|
8 posts
views
Thread by vj |
last post: by
|
3 posts
views
Thread by MarkW |
last post: by
|
4 posts
views
Thread by Patricia Mindanao |
last post: by
|
4 posts
views
Thread by billb |
last post: by
| | | | | | | | | | |