Gossamer Forum
Home : General : Perl Programming :

SIGNUP PAGE ON COMMUNIGATE

Quote Reply
SIGNUP PAGE ON COMMUNIGATE
im having a problem on our signup page.. can somebody here help me?

below is the script.. thanks



#!/usr/local/bin/perl
#
# This is a sample CGI program that displays a form where
# you should specify the account name, user's real name,
# password and mailbox type. After you click "Create" button
# it will connect to CGPro and create the account.
#
# Don't run it from the command shell if you don't know what you're doing.
#
# The CGPro's address and Postmaster login params should be
# defined manually in the script's text, see below.
#
#
my $CGServerAddress = "xxx.xxx.xxx.xxx";
my $PostmasterLogin = "postmaster";
my $PostmasterPassword = "********";
BEGIN
{
use FindBin qw($Bin);
use lib "$Bin";
}#This is for web server so it could find CLI.pm from the current directory
use strict;
use CLI;
use CGI qw(:standard);
print header; # Print "Context-type: text/html"
# print "<HTML>"
# print "<HEAD>User Creation Sample CGI</HEAD>"
# print "<BODY>"
print start_html("User Creation Sample CGI");
if($PostmasterPassword eq "") { # You didn't specify domain/login/password
errormsg("You have to modify the script file to specify the CGPro Server address and Postmaster password");
} elsif(param()) { # The form is already filled
# Read the parameters from the form
my $Account = param("account");
my $RealName = param("realname");
my $Password1 = param("password1");
my $Password2 = param("password2");
my $BoxType = param("boxtype");
my $RecoverPasswordAddr = param("recover");

if ($Account eq "") {
errormsg("No account name specified");
}
if ($Password1 eq "") {
errormsg("No password specified");
}
if ($Password1 ne $Password2) {
errormsg("Passwords do not match!");
}
my $cli = new CGP::CLI( { PeerAddr => $CGServerAddress,
PeerPort => 106,
login => $PostmasterLogin,
password => $PostmasterPassword } );
SecureLogin => 0
unless($cli) {
errormsg("Can't login to CGPro: ".$CGP::ERR_STRING);
last MAIN;
}
my $UserData;
@$UserData{'RealName'}=$RealName;
@$UserData{'Password'}=$Password1;
@$UserData{'RecoverPassword'}=$RecoverPasswordAddr if($RecoverPasswordAddr);
if($cli->CreateAccount(accountName => $Account,
accountType => $BoxType,
settings => $UserData)) {
print h1("Account created.");




print a({-href=>'CreateUserCGI.pl'},
'Create one more User<br>');
print a({-href=>"default.html?Username=$Account&Password=$Password1"},
'Open the created Account');
} else {
errormsg("Can't create '$Account' account: ".$cli->getErrMessage);
last MAIN;
}
$cli->Logout;
} else { # The form is empty
print h1("Create a user: "),hr();
print start_form();
print p("Account name: ",textfield("account"));
print p("Real name: ",textfield("realname"));
print p("Password: ",password_field("password1"));
print p("Password (again): ",password_field("password2"));
print p("Mailbox type: ",
popup_menu( "boxtype", ['TextMailbox','MultiMailbox','MailDirMailbox']));
print p("E-mail address to retrieve forgotten password: ",textfield("recover"));
print p(submit("Create"),reset("Clear"));
print end_form(),hr();
}
print end_html(); # print"</BODY></HTML>"
sub errormsg { #a procedure to output error message in HTML format and exit
my ($msg) = @_;
print h1("ERROR: $msg");
print a({-href=>'CreateUserCGI.pl'}, 'Create a User');
print end_html();
exit;
}
Quote Reply
Re: [c0d3z3r0] SIGNUP PAGE ON COMMUNIGATE In reply to
You haven't stated the problem.
Quote Reply
Re: [Hargreaves] SIGNUP PAGE ON COMMUNIGATE In reply to
the process cannot continue.. you can try it here http://mail.digitelone.com then sign up for a new account, i cant figure out if the problem is in login.pl or in CreateUserCGI itself.. thanks for the response, hope to hear from you again.. thanks...
Quote Reply
Re: [c0d3z3r0] SIGNUP PAGE ON COMMUNIGATE In reply to
No offence but I don't want to sign up. Can you not just tell us what error appears in your error log?

Just from looking I would think this is part of the problem:

my $UserData;
@$UserData{'RealName'}=$RealName;
@$UserData{'Password'}=$Password1;
@$UserData{'RecoverPassword'}=$RecoverPasswordAddr if($RecoverPasswordAddr);


Why all the @'s?.....also you are using UserData as a hash but declare it as a scalar.

Last edited by:

Hargreaves: Nov 24, 2005, 2:36 AM
Quote Reply
Re: [Hargreaves] SIGNUP PAGE ON COMMUNIGATE In reply to
im sorry but im totally not that familiar on perl.. but, do i have to remove the "@" sign on that part? thanks for your fast response.. do you want me to post the login.pl?
Quote Reply
Re: [c0d3z3r0] SIGNUP PAGE ON COMMUNIGATE In reply to
You also have a problem with this snippet:

Code:
my $cli = new CGP::CLI( { PeerAddr => $CGServerAddress,
PeerPort => 106,
login => $PostmasterLogin,
password => $PostmasterPassword } );
SecureLogin => 0


It should be:
Code:
my $cli = new CGP::CLI( {
PeerAddr => $CGServerAddress,
PeerPort => 106,
login => $PostmasterLogin,
password => $PostmasterPassword,
SecureLogin => 0,
});

Try that and see how far you get. Other than that, we need to see the errors from your error_log in order to help you.

~Charlie
Quote Reply
Re: [Chaz] SIGNUP PAGE ON COMMUNIGATE In reply to
thanks charlie? but how about this one? what should i do with this one? thanks for your response i appreciate your response...

my $UserData;
@$UserData{'RealName'}=$RealName;
@$UserData{'Password'}=$Password1;
@$UserData{'RecoverPassword'}=$RecoverPasswordAddr if($RecoverPasswordAddr);
Quote Reply
Re: [c0d3z3r0] SIGNUP PAGE ON COMMUNIGATE In reply to
Assuming you need a hashref:

Code:
my $UserData;
$UserData->{'RealName' } = $RealName;
$UserData->{'Password' } = $Password1;
$UserData->{'RecoverPassword'} = $RecoverPasswordAddr if($RecoverPasswordAddr);

The funny thing is, your original code didn't throw an error when I did a perl -c but I don't recognize that syntax.

~Charlie

Last edited by:

Chaz: Nov 25, 2005, 8:46 AM
Quote Reply
Re: [Chaz] SIGNUP PAGE ON COMMUNIGATE In reply to
Hmm, they're just using a hash slice. That bit of code is valid but it sure is a waste to use a slice that way. The code I provided above would be more readable but if you wanted to use a slice it would be more like this:

Code:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $slice;
@$slice{'test1', 'test2', 'test3'} = ('Test text 1', 'Test text 2', 'Test text 3');

print Dumper($slice) . $/;

~Charlie
Quote Reply
Re: [Chaz] SIGNUP PAGE ON COMMUNIGATE In reply to
yeah your correct, havent try this one before, ill keep you posted regarding the error.. thanks for your immediate response... Smile
Post deleted by Hargreaves In reply to

Last edited by:

Hargreaves: Nov 25, 2005, 6:01 PM