Hi All,
I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters?
Two codes below :
a) html
b) perl script (print and inserting into database)
Cheers...
Andrew
a) html
===== -
<!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HTML 3.2 + extensions for HoTMetaL PRO 3.0(U) 19961211//EN"
-
"hmpro3.dtd">
-
<HTML>
-
<HEAD>
-
<TITLE></TITLE></HEAD>
-
<BODY>
-
<FORM ACTION="/cgi-bin/acctman2.pl" METHOD="POST">
-
<CENTER>
-
<TABLE BORDER="0" WIDTH="400">
-
<TR>
-
<TD ALIGN="CENTER">
-
<TABLE BORDER="0" CELLPADDING="5" BGCOLOR="#FF8000">
-
<TR>
-
<TD><INPUT TYPE="CHECKBOX" NAME="agree" VALUE="agree"></TD>
-
<TD><FONT SIZE="-1" FACE="verdana, arial, helvetica"><B>I agree to the Terms
-
and Conditions above.</B></FONT></TD></TR></TABLE><BR></TD></TR>
-
<TR>
-
<TD>
-
<HR SIZE="2" NOSHADE="NOSHADE"></TD></TR>
-
<TR>
-
<TD ALIGN="CENTER">
-
<TABLE BORDER="0" WIDTH="350" NOWRAP="NOWRAP">
-
<TR>
-
<TD><FONT SIZE="-1" FACE="verdana, arial, helvetica"><B>Customer Information</B></FONT><BR><FONT
-
SIZE="-2" FACE="verdana, arial, helvetica" COLOR="#FF0000"><B>Fields marked
-
with an asterisk<BR>are required input fields.</B></FONT><BR><BR></TD></TR>
-
<TR>
-
<TD><INPUT TYPE="TEXT" NAME="fname">
-
<FONT SIZE="-1" FACE="verdana, arial, helvetica">First Name *</FONT></TD></TR>
-
<TR>
-
<TD><INPUT TYPE="TEXT" NAME="lname">
-
<FONT SIZE="-1" FACE="verdana, arial, helvetica">Last Name *</FONT></TD></TR>
-
<TR>
-
<TD><INPUT TYPE="TEXT" NAME="email">
-
<FONT SIZE="-1" FACE="verdana, arial, helvetica">E-Mail Address *</FONT></TD></TR></TABLE>
-
<TABLE BORDER="0" WIDTH="350" NOWRAP="NOWRAP">
-
<TR>
-
<TD><BR><FONT SIZE="-1" FACE="verdana, arial, helvetica"><B>Choose a User
-
Name</B></FONT><BR><INPUT TYPE="TEXT" NAME="username">
-
<FONT SIZE="-1" FACE="verdana, arial, helvetica">User Name</FONT>
-
<FONT SIZE="-1" FACE="arial, helvetica"><BR><BR><B>Choose a Password</B></FONT><BR>
-
-
<INPUT TYPE="password" NAME="pwd">
-
<FONT SIZE="-1" FACE="verdana, arial, helvetica">Password</FONT><BR><INPUT
-
TYPE="password" NAME="pwd2"> <FONT SIZE="-1" FACE="verdana, arial, helvetica">Verify
-
Password</FONT></TD></TR></TABLE><BR><BR><INPUT
-
TYPE="SUBMIT" NAME="process" VALUE="Submit My Order"><INPUT
-
TYPE="RESET" NAME=""></TD></TR>
-
<TR>
-
<TD>
-
<HR SIZE="2" NOSHADE="NOSHADE"></TD></TR></TABLE></CENTER></FORM></BODY></HTML>
-
b) perl script
========= -
#!c:\perl\bin\perl.exe
-
#!/usr/bin/perl
-
############################################
-
## ##
-
## Account Manager LITE User Signup ##
-
## by SiteInteractive.com ##
-
## http://siteinteractive.com/contact ##
-
## ##
-
## version: 1.09 ##
-
## last modified: 07/24/2002 ##
-
## copyright (c) 1998 - 2002 ##
-
## ##
-
## latest version is available from ##
-
## http://SiteInteractive.com ##
-
## ##
-
############################################
-
#
-
# Copyright 1998 Elite Host. All Rights Reserved.
-
#
-
# TERMS OF USE
-
# 1. Account Manager is for licensed customers
-
# only. Customer may use Account Manager as many
-
# times as customer wishes, as long as customer owns or runs the web
-
# site that Account Manager is installed on. Account
-
# Manager may not under any circumstances be sold
-
# or redistributed without the written consent of CGI Script Center and
-
# its owner Diran Alemshah.
-
#
-
# 2. CGI Script Center, at its own discresion, will decide if any terms
-
# of the this agreement have been violated by customer. Upon written e-
-
# mailed notification to Customer of Terms of Use violations, CGI
-
# Script Center may revoke customer's license to use Account Manager.
-
# In that event, Customer agrees to any and all of the following:
-
#
-
# a) Customers found in violation of this agreement, found reselling or
-
# redistributing Account Manager, or making
-
# Customers Members Area ID and password public to anyone in any
-
# manner will forfeit their Members area password and all rights to
-
# future versions of Account Manager.
-
#
-
# b). Customer will no longer be licensed to run any version of
-
# Account Manager.
-
#
-
# Indemnification
-
# 1. Customer agrees that it shall defend, indemnify, save and hold
-
# CGI Script Center, Elite Web Design and marketing, and any
-
# persons affiliated with either company, harmless from any and all
-
# demands, liabilities, losses, costs and claims, including reasonable
-
# attorney's fees asserted against CGI Script Center, its agents, its
-
# customers, officers and employees, that may arise or result from any
-
# service provided or performed or agreed to be performed or any product
-
# sold by customer, its agents, employees or assigns. Customer agrees to
-
# defend, indemnify and hold harmless CGI Script Center, its agents,
-
# its cusomters, officers, and employes,against
-
# liabilities arising out of; a) any injury to person or property caused
-
# by an products sold or otherwise distributed in connection with CGI
-
# Script Center products; (b) any material supplied by customer
-
# infringing or allegedly infringing on the proprietary rights of a
-
# third party; c) copyright infringement and (d) any defective products
-
# sold to customer from CGI Script Center products.
-
#
-
# This program may not be distributed in whole or part, freely, for pay,
-
# or any other form of compensation.
-
#
-
################################################## ###############
-
# This version designed for Win32 systems (NT). If you require
-
# a Unix version, please contact cgi@elitehost.com
-
################################################## ###############
-
-
-
################################################## ############
-
# EDIT USER CONFIGURATIONS BELOW
-
################################################## ############
-
-
# apache is in d DRIVE!!! not C
-
-
#require "d:/program files/apache software foundation/apache2.2/cgi-bin/config.pl";
-
-
# This completes this portion of your Account Manager setup
-
################################################## ############
-
# DO NOT EDIT BELOW THIS LINE
-
################################################## ############
-
-
use CGI;
-
use CGI::Carp qw(fatalsToBrowser);
-
use DBD::mysql;
-
use DBI;
-
-
my $query = CGI->new;
-
-
unless ($CGI::VERSION >= 2.47) {
-
error('Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.')
-
}
-
-
-
#SECTION B
-
#=========================================
-
#Database initialization and initial query
-
my ($dbh, $data_source);
-
my $mysql_server_name = 'localhost';
-
my $mysql_database_name = 'test';
-
my $mysql_user_name = 'root';
-
my $mysql_password = 'mysql1';
-
-
my $data_source = 'DBI:mysql:' . $mysql_database_name . ':' . $mysql_server_name;
-
my $dbh = DBI->connect( $data_source, $mysql_user_name, $mysql_password, {RaiseError=>1}) || die "$DBI::errstr";
-
-
-
-
-
#important line to pass email address from html to perl
-
my $agree_field = $query->param("agree") || 'Annonymous';
-
my $first_name = $query->param("fname") || 'Annonymous';
-
my $last_name = $query->param("lname") || 'Annonymous';
-
my $email_address = $query->param("email") || 'Annonymous';
-
my $user_name = $query->param("username") || 'Annonymous';
-
my $password = $query->param("pwd") || 'Annonymous';
-
-
-
# End of Database initial Query
-
#==========================================
-
-
print $query->header(),
-
$query->start_html(-title=>'Input Successful'),
-
$query->p('Thanks for registrating your particulars with us!'),
-
$query->p("You Agree? : $agree_field:"),
-
$query->p("Your First Name : $first_name"),
-
$query->p("Your last Name : $last_name"),
-
$query->p("Your email address: $email_address"),
-
$query->p("Your username : $user_name"),
-
$query->p("Your Password : $password"),
-
$query->end_html;
-
-
sub error {
-
print $query->header(),
-
$query->start_html(-title=>'Error'),
-
shift,
-
$query->end_html;
-
exit(0);
-
}
-
-
-
my $sql = $dbh->prepare(qq{SELECT * FROM user_reg});
-
$sql->execute();
-
-
while (my @data = $sql->fetchrow_array()) {
-
-
# Print the date from the first two columns in the table
-
#print $data[0], "\t", $data[1], "<br>";
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "\t", $data[4], "\t", $data[5], "<br>";
-
}
-
-
1;
-
-
-
$sql = $dbh->prepare(qq{insert into user_reg(agree_field, first_name, last_name, email_address, user_name, password) values ( "$agree_field", "$first_name", "$last_name", "$email_address", "$user_name", "$password") } );
-
$sql->execute() or die "$dbh->errstr\n";;
-
-
$sql = $dbh->prepare(qq{SELECT * FROM user_reg});
-
$sql->execute();
-
-
-
while (my @data = $sql->fetchrow_array()){
-
-
# 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>";
-
-
}
-
1;
-
-
Oct 20 '08
82 9946
Hi Jeff / All,
Thanks for all. Below is the error from strawberry perl cpan installation
Btw, DBI and DBD::MYSQL what is difference?
Thanks,
Andrew
ERROR
======
cpan shell -- CPAN exploration and modules installation (v1.9301)
ReadLine support enabled
cpan> install dbd::mysql
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/03modlist.data.gz
Database was generated on Mon, 27 Oct 2008 17:37:16 GMT
Updating database file ...
Gathering information from index files ...
Obtaining current state of database ...
Populating database tables ...
Done!
Warning: Cannot install dbd::mysql, don't know what it is.
Try the command
i /dbd::mysql/
to find objects with matching identifiers.
cpan> install dbd
Warning: Cannot install dbd, don't know what it is.
Try the command
i /dbd/
to find objects with matching identifiers.
cpan> install dbd::mysql;
Warning: Cannot install dbd::mysql;, don't know what it is.
Try the command
i /dbd::mysql;/
to find objects with matching identifiers.
Try:
perl is case sensitive. DBD not dbd
even the below didnt help. Thanks.
ERROR 2
--------------
cpan> install DBD::mysql
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Checksum for C:\strawberry\cpan\sources\authors\id\C\CA\CAPTTOF U\DBD-mysql-4.010
.tar.gz ok
Scanning cache C:\strawberry\cpan\build for sizes
.................................................. ..........................DONE
CPAN.pm: Going to build C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Use of uninitialized value $ENV{"USER"} in concatenation (.) or string at Makefi
le.PL line 488.
Use of uninitialized value in concatenation (.) or string at Makefile.PL line 48
8.
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user '' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to ''@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
Warning: No success on command[C:\strawberry\perl\bin\perl.exe Makefile.PL]
CAPTTOFU/DBD-mysql-4.010.tar.gz
C:\strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Failed during this command:
CAPTTOFU/DBD-mysql-4.010.tar.gz : writemakefile NO 'C:\strawberry\
perl\bin\perl.exe Makefile.PL' returned status 512
Hi Kevin,
Thanks. Think it was installed even before I installed, but cant really make test... Not sure what is wrong...?
Thanks,
Andrew
PROBLEM :
=========
cpan> install DBD::mysql
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Has already been unwrapped into directory C:\strawberry\cpan\build\DBD-mysql-4
.010-IKl04x
'C:\strawberry\perl\bin\perl.exe Makefile.PL' returned status 512, won't make
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Hi Kevin,
The code is below. Not sure if declared correctly?
Thanks in advance again,
Andrew -
-
#!c:\strawberry\perl\bin\perl.exe
-
#!c:\perl\bin\perl.exe
-
#!perl
-
#!/usr/bin/perl -T
-
use strict;
-
use warnings;
-
use CGI;
-
use CGI::Carp qw(fatalsToBrowser);
-
use File::Basename;
-
use DBD::mysql;
-
use DBI;
-
-
-
$CGI::POST_MAX = 1024 * 5000; #adjust as needed (1024 * 5000 = 5MB)
-
$CGI::DISABLE_UPLOADS = 0; #1 disables uploads, 0 enables uploads
-
-
my $query = CGI->new;
-
-
unless ($CGI::VERSION >= 2.47) {
-
error('Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.')
-
}
-
-
-
#SECTION B
-
#=========================================
-
#Database initialization and initial query
-
my ($dbh, $data_source);
-
my $mysql_server_name = 'localhost';
-
my $mysql_database_name = 'test';
-
my $mysql_user_name = 'root';
-
my $mysql_password = 'mysql1';
-
-
my $data_source = 'DBI:mysql:' . $mysql_database_name . ':' . $mysql_server_name;
-
my $dbh = DBI->connect( $data_source, $mysql_user_name, $mysql_password, {RaiseError=>1}) || die "$DBI::errstr";
-
-
-
my $sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
while (my @data = $sql->fetchrow_array()) {
-
-
# Print the date from the first two columns in the table
-
print $data[0], "\t", $data[1], "<br>";
-
}
-
-
1;
-
-
# End of Database initial Query
-
#==========================================
-
-
-
-
-
my $upload_dir = 'D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/upload';
-
-
# a list of valid characters that can be in filenames
-
my $filename_characters = 'a-zA-Z0-9_.-';
-
-
my $file = $query->param("photo") or error('No file selected for upload.') ;
-
my $email_address = $query->param("email") || 'Annonymous';
-
-
# get the filename and the file extension
-
# this could be used to filter out unwanted filetypes
-
# see the File::Basename documentation for details
-
my ($filename,undef,$ext) = fileparse($file,qr{\..*});
-
-
# append extension to filename
-
$filename .= $ext;
-
-
# convert spaces to underscores "_"
-
$filename =~ tr/ /_/;
-
-
# remove illegal characters
-
$filename =~ s/[^$filename_characters]//g;
-
-
# satisfy taint checking
-
if ($filename =~ /^([$filename_characters]+)$/) {
-
$filename = $1;
-
}
-
else{
-
error("The filename is not valid. Filenames can only contain these characters: $filename_characters")
-
}
-
-
# this is very crude but validating an email address is not an easy task
-
# and is beyond the scope of this article. To validate an email
-
# address properly use the Emaill::Valid module. I do not include
-
# it here because it is not a core module.
-
unless ($email_address =~ /^[\w@.-]+$/ && length $email_address < 250) {
-
error("The email address appears invalid or contains too many characters. Limit is 250 characters.")
-
}
-
-
my $upload_filehandle = $query->upload("photo");
-
-
open (UPLOADFILE, ">$upload_dir/$filename") or error($!);
-
binmode UPLOADFILE;
-
while ( <$upload_filehandle> ) {
-
print UPLOADFILE;
-
}
-
close UPLOADFILE;
-
-
-
print $query->header(),
-
$query->start_html(-title=>'Upload Successful'),
-
$query->p('Thanks for uploading your photo!'),
-
$query->p("Your email address: $email_address"),
-
$query->p("Your photo $filename:"),
-
$query->img({src=>"../upload/$filename",alt=>''}),
-
$query->end_html;
-
-
-
sub error {
-
print $query->header(),
-
$query->start_html(-title=>'Error'),
-
shift,
-
$query->end_html;
-
exit(0);
-
}
-
-
-
$sql = $dbh->prepare(qq{insert into samples(username, password, email_address, filename) values ( "userhello636", "passhello636", "$email_address", "$filename") } );
-
$sql->execute() or die "$dbh->errstr\n";;
-
-
$sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
-
while (my @data = $sql->fetchrow_array()){
-
-
# Print the date from the first four columns in the table
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "<br>";
-
-
}
-
1;
-
-
Hi Kevin,
The code is below. Not sure if declared correctly?
Thanks in advance again,
Andrew -
-
#!c:\strawberry\perl\bin\perl.exe
-
#!c:\perl\bin\perl.exe
-
#!perl
-
#!/usr/bin/perl -T
-
use strict;
-
use warnings;
-
use CGI;
-
use CGI::Carp qw(fatalsToBrowser);
-
use File::Basename;
-
use DBD::mysql;
-
use DBI;
-
-
-
$CGI::POST_MAX = 1024 * 5000; #adjust as needed (1024 * 5000 = 5MB)
-
$CGI::DISABLE_UPLOADS = 0; #1 disables uploads, 0 enables uploads
-
-
my $query = CGI->new;
-
-
unless ($CGI::VERSION >= 2.47) {
-
error('Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.')
-
}
-
-
-
#SECTION B
-
#=========================================
-
#Database initialization and initial query
-
my ($dbh, $data_source);
-
my $mysql_server_name = 'localhost';
-
my $mysql_database_name = 'test';
-
my $mysql_user_name = 'root';
-
my $mysql_password = 'mysql1';
-
-
my $data_source = 'DBI:mysql:' . $mysql_database_name . ':' . $mysql_server_name;
-
my $dbh = DBI->connect( $data_source, $mysql_user_name, $mysql_password, {RaiseError=>1}) || die "$DBI::errstr";
-
-
-
my $sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
while (my @data = $sql->fetchrow_array()) {
-
-
# Print the date from the first two columns in the table
-
print $data[0], "\t", $data[1], "<br>";
-
}
-
-
1;
-
-
# End of Database initial Query
-
#==========================================
-
-
-
-
-
my $upload_dir = 'D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/upload';
-
-
# a list of valid characters that can be in filenames
-
my $filename_characters = 'a-zA-Z0-9_.-';
-
-
my $file = $query->param("photo") or error('No file selected for upload.') ;
-
my $email_address = $query->param("email") || 'Annonymous';
-
-
# get the filename and the file extension
-
# this could be used to filter out unwanted filetypes
-
# see the File::Basename documentation for details
-
my ($filename,undef,$ext) = fileparse($file,qr{\..*});
-
-
# append extension to filename
-
$filename .= $ext;
-
-
# convert spaces to underscores "_"
-
$filename =~ tr/ /_/;
-
-
# remove illegal characters
-
$filename =~ s/[^$filename_characters]//g;
-
-
# satisfy taint checking
-
if ($filename =~ /^([$filename_characters]+)$/) {
-
$filename = $1;
-
}
-
else{
-
error("The filename is not valid. Filenames can only contain these characters: $filename_characters")
-
}
-
-
# this is very crude but validating an email address is not an easy task
-
# and is beyond the scope of this article. To validate an email
-
# address properly use the Emaill::Valid module. I do not include
-
# it here because it is not a core module.
-
unless ($email_address =~ /^[\w@.-]+$/ && length $email_address < 250) {
-
error("The email address appears invalid or contains too many characters. Limit is 250 characters.")
-
}
-
-
my $upload_filehandle = $query->upload("photo");
-
-
open (UPLOADFILE, ">$upload_dir/$filename") or error($!);
-
binmode UPLOADFILE;
-
while ( <$upload_filehandle> ) {
-
print UPLOADFILE;
-
}
-
close UPLOADFILE;
-
-
-
print $query->header(),
-
$query->start_html(-title=>'Upload Successful'),
-
$query->p('Thanks for uploading your photo!'),
-
$query->p("Your email address: $email_address"),
-
$query->p("Your photo $filename:"),
-
$query->img({src=>"../upload/$filename",alt=>''}),
-
$query->end_html;
-
-
-
sub error {
-
print $query->header(),
-
$query->start_html(-title=>'Error'),
-
shift,
-
$query->end_html;
-
exit(0);
-
}
-
-
-
$sql = $dbh->prepare(qq{insert into samples(username, password, email_address, filename) values ( "userhello636", "passhello636", "$email_address", "$filename") } );
-
$sql->execute() or die "$dbh->errstr\n";;
-
-
$sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
-
while (my @data = $sql->fetchrow_array()){
-
-
# Print the date from the first four columns in the table
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "<br>";
-
-
}
-
1;
-
-
Do You get any error messages?
what do you mean your not sure?
The following, the first 4 lines of your code, are not correct: -
# #!c:\strawberry\perl\bin\perl.exe
-
# #!c:\perl\bin\perl.exe
-
# #!perl
-
# #!/usr/bin/perl -T
-
The shebang line is ONLY the first line of your script. It starts with a "#!" as the first two characters and from the third character on is the path to your Perl interpreter. The way you have it, with two # signs will not work. You only need one of these, the other three are comments.
The shebang line can only be on the first line, otherwise you need to kick off the script with the perl program name preceeding it.
Regards,
Jeff
I don't see two # signs. Did you copy and past his code into a text file or text editor? The first # sign was maybe the line number artifact.
Hi Guys,
I did modification to be reduced to 1 line of interpretor. Still didnt work. Kindly adviise. The Error in html, the code and cpan installation errors are shown below. Thanks again!
Thanks and Best Rgds,
Andrew
Error shown in html page
==================
Software error:
Can't locate DBD/mysql.pm in @INC (@INC contains: C:/strawberry/perl/lib C:/strawberry/perl/site/lib .) at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/u3.pl line 7.
BEGIN failed--compilation aborted at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/u3.pl line 7.
For help, please send mail to the webmaster (admin@gateway.2wire.net), giving this error message and the time and date of the error. -
#!c:\strawberry\perl\bin\perl.exe
-
use strict;
-
use warnings;
-
use CGI;
-
use CGI::Carp qw(fatalsToBrowser);
-
use File::Basename;
-
use DBD::mysql;
-
use DBI;
-
-
-
$CGI::POST_MAX = 1024 * 5000; #adjust as needed (1024 * 5000 = 5MB)
-
$CGI::DISABLE_UPLOADS = 0; #1 disables uploads, 0 enables uploads
-
-
my $query = CGI->new;
-
-
unless ($CGI::VERSION >= 2.47) {
-
error('Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.')
-
}
-
-
-
#SECTION B
-
#=========================================
-
#Database initialization and initial query
-
my ($dbh, $data_source);
-
my $mysql_server_name = 'localhost';
-
my $mysql_database_name = 'test';
-
my $mysql_user_name = 'root';
-
my $mysql_password = 'mysql1';
-
-
my $data_source = 'DBI:mysql:' . $mysql_database_name . ':' . $mysql_server_name;
-
my $dbh = DBI->connect( $data_source, $mysql_user_name, $mysql_password, {RaiseError=>1}) || die "$DBI::errstr";
-
-
-
my $sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
while (my @data = $sql->fetchrow_array()) {
-
-
# Print the date from the first two columns in the table
-
print $data[0], "\t", $data[1], "<br>";
-
}
-
-
1;
-
-
# End of Database initial Query
-
#==========================================
-
-
-
-
-
my $upload_dir = 'D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/upload';
-
-
# a list of valid characters that can be in filenames
-
my $filename_characters = 'a-zA-Z0-9_.-';
-
-
my $file = $query->param("photo") or error('No file selected for upload.') ;
-
my $email_address = $query->param("email") || 'Annonymous';
-
-
# get the filename and the file extension
-
# this could be used to filter out unwanted filetypes
-
# see the File::Basename documentation for details
-
my ($filename,undef,$ext) = fileparse($file,qr{\..*});
-
-
# append extension to filename
-
$filename .= $ext;
-
-
# convert spaces to underscores "_"
-
$filename =~ tr/ /_/;
-
-
# remove illegal characters
-
$filename =~ s/[^$filename_characters]//g;
-
-
# satisfy taint checking
-
if ($filename =~ /^([$filename_characters]+)$/) {
-
$filename = $1;
-
}
-
else{
-
error("The filename is not valid. Filenames can only contain these characters: $filename_characters")
-
}
-
-
# this is very crude but validating an email address is not an easy task
-
# and is beyond the scope of this article. To validate an email
-
# address properly use the Emaill::Valid module. I do not include
-
# it here because it is not a core module.
-
unless ($email_address =~ /^[\w@.-]+$/ && length $email_address < 250) {
-
error("The email address appears invalid or contains too many characters. Limit is 250 characters.")
-
}
-
-
my $upload_filehandle = $query->upload("photo");
-
-
open (UPLOADFILE, ">$upload_dir/$filename") or error($!);
-
binmode UPLOADFILE;
-
while ( <$upload_filehandle> ) {
-
print UPLOADFILE;
-
}
-
close UPLOADFILE;
-
-
-
print $query->header(),
-
$query->start_html(-title=>'Upload Successful'),
-
$query->p('Thanks for uploading your photo!'),
-
$query->p("Your email address: $email_address"),
-
$query->p("Your photo $filename:"),
-
$query->img({src=>"../upload/$filename",alt=>''}),
-
$query->end_html;
-
-
-
sub error {
-
print $query->header(),
-
$query->start_html(-title=>'Error'),
-
shift,
-
$query->end_html;
-
exit(0);
-
}
-
-
-
$sql = $dbh->prepare(qq{insert into samples(username, password, email_address, filename) values ( "userhello636", "passhello636", "$email_address", "$filename") } );
-
$sql->execute() or die "$dbh->errstr\n";;
-
-
$sql = $dbh->prepare(qq{SELECT * FROM samples});
-
$sql->execute();
-
-
-
while (my @data = $sql->fetchrow_array()){
-
-
# Print the date from the first four columns in the table
-
print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "<br>";
-
-
}
-
1;
-
-
CPAN install of DBD::mysql
=====================
cpan> install DBD::mysql
Database was generated on Wed, 29 Oct 2008 07:52:22 GMT
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Checksum for C:\strawberry\cpan\sources\authors\id\C\CA\CAPTTOF U\DBD-mysql-4.010
.tar.gz ok
Scanning cache C:\strawberry\cpan\build for sizes
.................................................. ..........................DONE
CPAN.pm: Going to build C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Use of uninitialized value $ENV{"USER"} in concatenation (.) or string at Makefi
le.PL line 488.
Use of uninitialized value in concatenation (.) or string at Makefile.PL line 48
8.
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user '' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to ''@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
Warning: No success on command[C:\strawberry\perl\bin\perl.exe Makefile.PL]
CAPTTOFU/DBD-mysql-4.010.tar.gz
C:\strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Failed during this command:
CAPTTOFU/DBD-mysql-4.010.tar.gz : writemakefile NO 'C:\strawberry\
perl\bin\perl.exe Makefile.PL' returned status 512
Edit.... comments removed.
Hi Kevin,
??? What happened?
Thanks in advance,
Andrew
Hi Kevin / All,
Any one can help on how to make the DBD::mysql above work in strawberry perl cpan?
Appreciated.
Cheers...
Andrew
Hi Kevin,
??? What happened?
Thanks in advance,
Andrew
Nothing, I posted something then realized it was wrong or irrelevant so I removed my comments. I don't even remember now what it was.
Regards,
Kevin
Hi Kevin,
Thanks! How to shed some light on the DBD::mysql above? Appreciated again.
Cheers..
Andrew
Hi All,
I tried strawberry perl to compile DBD::mysql and got the error below. Any idea how to resolve, tried to download earlier version DBD::mysql 4.09 instead of current 4.10. But still cant work....???
Thanks in advance,
Andrew -
-
cpan> install DBD:mysql
-
Running install for module 'DBD::mysql'
-
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
-
Has already been unwrapped into directory C:\strawberry\cpan\build\DBD-mysql-4
-
.010-N1_HUn
-
'C:\strawberry\perl\bin\perl.exe Makefile.PL' returned status 512, won't make
-
Running make test
-
Make had some problems, won't test
-
Running make install
-
Make had some problems, won't install
-
-
I deleted all the necessary perl installation and removed the entire perl programs and reinstalled everything after rebooting but was unable to get DBD::mysql working... Kindly HELP!! Thanks!
Sorry, I don't use strawberry perl and I have no idea what the problem is. Hopefully Jeff can help you out.
I don't know if it matters, but do you have mysql installed? I just uninstalled Strawberry Perl, re-installed it, tried to install DBD::mysql module and it failed in a similar maner. I don't have mysql installed so I can only imagine that is why the 'test' failed.
Regards,
Jeff
MySQL does have to be installed before you can add the DBD module for the DBI. Also, it has to either be on the same drive as Strawberry or in the setup you have to point it to where the mysql executable is located.
--Kevin
MySQL does have to be installed before you can add the DBD module for the DBI. Also, it has to either be on the same drive as Strawberry or in the setup you have to point it to where the mysql executable is located.
--Kevin
Its always a good idea to put the path to where the executable is located, in your system path. That way it can easily be found.
BTW, I was pretty positive on that but thanks for backing me up Kevin. I confirmed it after I posted it.
Regards,
Jeff
Hi Kevin and Jeff,
Thanks again, after testing and trying out many times, I guess I am closer but why still so far far away.??? The mysql server is installed in c:drive(cant select drive), so is strawberry perl. STILL Very confused.
Thanks in advance
Andrew
Tried 4 methods which recommended by install.html, especially instruction from item e) below.
a) The CPAN installation still gives the error below.
b) strawberry makefile installation problem (followed install.html in strawberry perl)
c) side track abit(mysql connection manually from dos, having problem, not sure it is related to this problem, and what is the syntax?)
d) Error in mysql compilation as suggested by Install.html in strawberry perl
a) Error CPAN
===========
cpan> install DBD::mysql
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Has already been unwrapped into directory C:\strawberry\cpan\build\DBD-mysql-4
.010-y0lPqJ
'C:\strawberry\perl\bin\perl.exe Makefile.PL' returned status 512, won't make
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
b) strawberry perl "perl makefile.PL" problem
================================
C:\strawberry\perl\bin>perl Makefile.Pl
Can't open perl script "Makefile.Pl": No such file or directory
C:\strawberry\perl\bin>perl Makefile.PL
Can't open perl script "Makefile.PL": No such file or directory
C:\strawberry\perl\bin>perl Makefile.PL --testdb=test
Can't open perl script "Makefile.PL": No such file or directory
c) mysql connection error - can login via sqylog using correct username and password
================================================== =====
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql mysql@localhost
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql mysql1@localhost
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
C:\Program Files\MySQL\MySQL Server 5.0\bin>
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql root@mysql1
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
d) Error in mysql compilation as suggested by Install.html in strawberry perl
================================================== ====
===========================
C:\DBD-mysql-4.010>dir'
'dir'' is not recognized as an internal or external command,
operable program or batch file.
C:\DBD-mysql-4.010>dir
Volume in drive C has no label.
Volume Serial Number is CCD0-09FB
Directory of C:\DBD-mysql-4.010
10/31/2008 01:10 AM <DIR> .
10/31/2008 01:10 AM <DIR> ..
10/24/2008 06:58 AM 58,378 ChangeLog
12/05/2007 06:09 PM 2,043 constants.h
10/24/2008 06:38 AM 133,706 dbdimp.c
04/28/2008 04:36 PM 10,506 dbdimp.h
10/31/2008 01:10 AM <DIR> eg
10/24/2008 06:58 AM 30,182 INSTALL.html
10/31/2008 01:10 AM <DIR> lib
08/15/2008 06:24 AM 23,805 Makefile.PL
12/23/2006 09:54 AM 748 Makefile.PL.embedded
05/11/2008 08:24 AM 1,185 MANIFEST
01/03/2007 07:14 PM 45 MANIFEST.SKIP
10/24/2008 06:58 AM 392 META.yml
01/03/2007 07:14 PM 1,770 myld
08/15/2008 06:00 AM 19,198 mysql.xs
08/15/2008 06:26 AM 3,512 README
10/31/2008 01:10 AM <DIR> t
12/23/2006 09:54 AM 914 TODO
14 File(s) 286,384 bytes
5 Dir(s) 23,378,735,104 bytes free
C:\DBD-mysql-4.010>Makefile.pl
C:\DBD-mysql-4.010>c:\strawberry\perl\bin\perl.exe Makefile.PL
Use of uninitialized value $ENV{"USER"} in concatenation (.) or string at Makefi
le.PL line 488.
Use of uninitialized value in concatenation (.) or string at Makefile.PL line 48
8.
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user '' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to ''@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
C:\DBD-mysql-4.010>c:\strawberry\perl\bin\perl.exe Makefile.PL
Use of uninitialized value $ENV{"USER"} in concatenation (.) or string at Makefi
le.PL line 488.
Use of uninitialized value in concatenation (.) or string at Makefile.PL line 48
8.
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user '' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to ''@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
C:\DBD-mysql-4.010>make
'make' is not recognized as an internal or external command,
operable program or batch file.
C:\DBD-mysql-4.010>make
e) install.html instruction in strawberry perl
==============================
(On Windows you may need to replace ``make'' with ``nmake'' or ``dmake''.) If the tests seem to look fine, you may continue with
make install
If the compilation (make) or tests fail, you might need to configure some settings.
For example you might choose a different database, the C compiler or the linker might need some flags. Configuration. Compiler flags. Linker flags.
For Windows/CygWin there is a special section below. Windows/CygWin.
Configuration
The install script ``Makefile.PL'' can be configured via a lot of switches. All switches can be used on the command line. For example, the test database:
perl Makefile.PL --testdb=<db>
If you do not like configuring these switches on the command line, you may alternatively create a script called mysql_config. This is described later on.
Available switches are:
Also, I uninstall latest module of mysql in c:, but cannot put it to good use, why??
Also, I uninstall latest module of mysql in c:, but cannot put it to good use, why??
i meant unzip to C:\DBD-mysql-4.010>, not uninstall.. thanks,,,
Hi Sirs,
Any idea on #70 and #72 post above? Thanks in advance.
Andrew
Sorry any suggestionsss on #71 and #73 posts???? not #70 and #72 posts.
Thanks again,
Andrew
Hi All,
I would really appreciate if anyone can shed some lights on is it possible to install DBD::mysql into windows xp pro's strawberry perl.
Had gone through yahoo and google search engines and it seemed that alot of people are stuck with this?
Shall I use back activestate perl??? or any other alternative??
Please... For goodness sake, anyone can kindly advise?
Thanks in advance,
Andrew
I am not ignoring your post, I just don't have an answer for you. I have Strawberry Perl on my system only for when I do Windows coding, which at my last job was a lot more often since that was what they used. At my present job everything is Linux/Unix and believe me, I prefer it that way.
I tried installing DBD:mysql in Strawberry Perl and also ran into a ton of issues. Being that I don't have a ton of time to try and figure them out, I don't have any answer for you. You could always ask on Perlmonks if anyone over there has any more experience with it.
Regards,
Jeff
Hi Jeff,
Thanks! I feel the difficulties also, this is a good news for the development.
Can I use linux OS on my windows xp as second layer OS in my development because I am using windows xp.?? or have other type of perl engine?
Thanks again,
Andrew
the problem i am worried is linux is not easy to configure? and not user friendly?
Thanks,
Andrew
Hi Guys,
Any light?
Cheers...
Andrew
Sorry, been away and busy for a day or so.
Linux is an excellent operating system. While it is quite the change from Windows, most everyone I know who has switched to it has done so and LOVED it. Granted, there are those that are the exception to the rule, but I would say that 98% of those I turn to Linux stick with it and a bunch of them ditch it all together (although that is not an easy prospect for most, but quite possible).
If you wanted to try Linux, I would suggest that you try one of the following options:
1. Try a live distribution, which runs without overwriting what is installed on your pc. You boot from the disk (which you download and burn first) and you can try it out to see if you like it.
2. You can install Linux to a USB stick. I did this with a 2 gig stick using pendrivelinux.com and its pretty easy with their instructions. If you go with a bigger pen drive, you will have more space to play with for development.
3. Download and install vmware (server version is FREE) and install Linux into it to play with.
If you go with option 1 or 3, I would recommend trying something like Suse Linux or Fedora, which are a bit more user friendly and don't require as much Linux knowledge up front. For #2, there are versions mentioned in their installation instructions and you can just pick one.
Either way, I don't know what the issue is with installing the module under Windows. Its odd and I get similar issues. Also, Active State and Strawberry perl are pretty much the only Window$ Perl ports.
Regards,
Jeff
I would suggest that you either make a new thread in the Linux forum for help with the installation of Linux or you could contact a computer company local to you, and have them install it for you. I only mention this because you have had several problems and this is delaying your progress.
--Kevin
Thanks Sirs!
I will bear that in mind, only thing is I will first write the codes in windows activestate as I am running out of time... If the website launched successfully I will change to linux if need be...
Cheers...
Andrew
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason Miles |
last post by:
Hi,
I wrote this little script to check to see if our Lotus Notes servers are
running, and from the command line it works fine if I type perl
notescheck.pl
When I invoke the script from a web...
|
by: Craig |
last post by:
I have an Access 2000 database that has a table 'tblCourse' and a
table 'tblRegistration'.
They are linked via a Primary key 'CourseID' in 'tblCourse' to a
foreign key 'CourseID' in the...
|
by: Perks |
last post by:
Hi.
I am trying to find out if it is possible to open a pdf file from
within PHP, and parse its contents in order to extract all form
fieldnames that might have been previously setup within the...
|
by: Frinavale |
last post by:
Filtering user input is extremely important for web programming.
If input is left unfiltered users can input malicious code that can cripple your website.
This article will explain how to make...
|
by: Anshul |
last post by:
I want to check through perl whether javascript is enabled or disabled
in mozilla browser. If it is disabled I want to display a message to
user to enable it. What code can I use please help.
I...
|
by: plumba |
last post by:
Let me explain....
I have a form (most of which you guys have helped me with!!). The initial problem I was having is that it was holding the data in the fields after submit, I resolved this by...
|
by: owlice |
last post by:
Greetings!
I thought I'd add a little something to a web site, a "tip of the week," and wanted it automated so that if I get hit by a truck (or, more likely, am forgetful), the tip is updated...
|
by: patelxxx |
last post by:
I have a FORM with allows user to input their name and then user clicks submit which this goes to my .cgi script. Can someone check this .cgi script as the results are not being displayed as...
|
by: polycom |
last post by:
Hi,
I am coding a mysql health check script. The logic is to execute the commands (only once)show status,show slave status,show variables and fetch the variable name and value in a hash refer or...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |