Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR LOOP problem and mailto Issue.......Bugger

Status
Not open for further replies.

madaxe

Technical User
Dec 21, 2004
44
0
0
US
When my password field is empty and i hit submit it gets stuck in a loop involving the sub error and i get a popup box coming up continualy i tried using an unless statement but i cant get it to work all my form scalars are being set correctly i see the values in the error popup box.

Also i cant get my mailto line to work.

Can anybody help

MadAxe

Code:
##########################################################################


open (USERLIST, "$userlist");
@userlist = <USERLIST>;
close (USERLIST);


foreach $dataline (@userlist){
    chomp $dataline;
    ($username, $password) = split(/\|/, $dataline);

if  ($username eq $sender) {
	if ($password eq $pass) {


print "mailto:$email subject=$subject body=$content\n";


		}
	}
}


################################################################################

if  ($password ne $pass) {
	&error;
}
unless ($pass eq "") {

}
############################# Sub Programmes ###################################


sub error {
print <<EndStart;
<HTML>
<HEAD>
<script type="text/javascript">
<!--

alert ("INCORECT PASSWORD. $pass $password $username $sender")

// -->
</script>
</HEAD> 
EndStart
print "<html><head><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=$failedlogin\"></head></html>\n";
print "<a href=\"$failedlogin\">Click here to contine!</a>";
exit;
}
 
I am not sure about the amount of username passwords in the @userlist, but your script goes through all the lines to check if the username inserted is there and if the right password was given. Since none if the lines have a password “” it will go through all the lines untill it is at the end… and all those times it will go through the error sub.

I suspect you are not getting an infinit loop. Right?

Best thing would be to put the username passwords in a hash and check if the username excist and if the password is okay… this way you do not have to go by all the username/password pairs

BTW. I am a novice when it comes to perl and the code is done by head without any reference..

Code:
open (USERLIST, "$userlist");
@userlist = <USERLIST>;
close (USERLIST);

foreach $dataline (@userlist)
  {
    ($username, $password) = split(/\|/, $dataline);
    $pwdusernamehash($username) = $password;
  }

If ($pwdusernamehash($sender) = $pass)
  {
    print "mailto:$email subject=$subject body=$content\n";
  }
Else 
  {
    &error
  }

InDenial

 
Here is the problem: The meta refresh on the page does not cause any new data, causing the error alert to be displayed again, after which refreshing the page, which again errors, since there is no new data and prints out the alert, which then refreshes, and ...

You might want to consider remedying that...

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Hi Chessbot

Man way over my head im still learning i only started learning 2 weeks ago and already i have learnt a fare bit, but meta refresh??????

what is it.....

Its a stasis leak

what is it..

its a stasis leak in the fabric of time..

what is it..

Can you surgest a fix for my problem?

Madaxe

 
print "<html><head><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=$failedlogin\">";

chessbot was most likely pointing to this, and saying that $failedlogin is blank



cigless ...
 
Hi Madaxe

As InDenial suggests - try reading up on hashes

Code:
[b]#!/usr/bin/perl[/b]

$password{"Duncan Carr"} = "abc123";
$password{"Mad Axeman"}  = "xyz456789";
$password{"In Denial"}   = "blahblahblah";

print "please input a name: ";

chomp ($name = <STDIN>);

if (exists $password{"$name"}) {
  print "password is: $password{\"$name\"}\n";
} else {
  print "no password found...\n";
}


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top