INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Redirect to another page using cgi

Redirect to another page using cgi

(OP)
want to redirect the client to the another page after the password is unmatched. I have a cgi at server end and need to redirect.

My code :
#!/usr/bin/perl

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
require 'globalvariables.pl';
# Get STDIN: the input from the post
read(STDIN, $stdin, $ENV{'CONTENT_LENGTH'});
#print "Content-Type: text/plain\n\n" ;
#print $stdin;

#variables values
$filename = 'annotationTools/perl/testlocation.txt';
$actualpass = " ";
$current_username = '';
$current_password = '';
$current_startpage = '';
$current_lastpage = '';
$current_collection = '';

#values of the post
($current_username,$current_password)= split(/&/,$stdin);

#print $temp_user;
#print $temp_pass;

if(!open(FP,$LM_HOME.$filename)) {
print "Status: 404\n\n";
return;
}
@lines = readline(FP);
@twodimarray;
$lines=0;
$passwordmatch =0;
foreach $i (@lines) {
($login, $passwd, $from,$till,$collection)= split(/,/,$i);
$indexlog = index($login, '=');
$indexpass = index($passwd, '=');
$indexstart = index($from, '=');
$indexend = index($till, '=');
$indexcollection = index($collection, '=');

$loginval = substr $login, $indexlog+1;
$passwdval = substr $passwd, $indexpass+1;
$startval= substr $from, $indexstart+1;
$endval= substr $till, $indexend+1;http:///xmltest.shtml
$collectionval = substr $collection, $indexcollection+1;

$twodimarray = $loginval;
$twodimarray = $passwdval;
$twodimarray = $startval;
$twodimarray = $endval;
$twodimarray = $collectionval;
$lines++;
}

for ($init = 0; $init < $lines; $init++) {
$usertemp = $twodimarray;

if($current_username eq $usertemp)
{
$passtemp = $twodimarray;
if($current_password eq $passtemp)
{
# print 'ACK';
}
else {
$query= new CGI;
print $query->redirect(-url => 'index_test.shtml');
}


}
}
close(FP);

The client end html page is :

<html>
<script type="text/javascript" src="annotationTools/js/md5.js" ></script>
<body>
<script>
var constantusrname= 'xxx';
var constantpass = 'xxxx';
function onCheck(){

var hash = CryptoJS.MD5(constantpass);
var url = 'session_test.cgi';

// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req_anno = new XMLHttpRequest();
req_anno.open("POST", url, false);
req_anno.send(constantusrname+'&'+hash);
}
else if (window.ActiveXObject) {
req_anno = new ActiveXObject("Microsoft.XMLHTTP");
if (req_anno) {
req_anno.open("POST", url, false);
req_anno.send();
}
}

}

</script>
<input type="button" id = "btnSearch" value = "submit" onclick='onCheck()' />

</body>
</html>

the problem is that when the user press click the page is not being navigated by the cgi on the client browser.

In the firebug the console shows that the index_test.shtml is being get but the user webpage is not redirected it is on the same page.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close