Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 31st, 2004, 01:50 PM
isustu23 isustu23 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 isustu23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Possible to Redirect to a URL???

Hi, I have this script that accepts data passed from a form, and im trying to redirect to a url after it processes the data and sends the email. Is this possible or any suggestions? ...this is the python code


#!/usr/local/bin/python
import cgi, os, re

sendmail="/bin/sendmail -t"

def print_header():
print "Content-type: text/html"
print
print "<HTML>"
print "<HEAD><TITLE>SEND MAIL FORM</TITLE></HEAD>"
print "<BODY>"

def disp_query (form):
AllFieldsOk=1
fields = form.keys()
##################################
# Check all input field are full #
##################################
if not 'FirstName' in fields : AllFieldsOk=0
if not 'LastName' in fields : AllFieldsOk=0
if not 'E-mail' in fields : AllFieldsOk=0
else :
if not "@" in form['E-mail'] :
print "Bad E-mail address<BR>"
AllFieldsOk=0
if not 'Comments' in fields : AllFieldsOk=0

if AllFieldsOk == 0 :
print "One field or more in the form is empty<BR>"
print "Go back to the previous page and fill all the fields"
else:
fp = os.popen(sendmail, "w")
fp.write("To: %s\n" % form['DEST_EMAIL'])
fp.write("from: %s\n" % form['E-mail'])
fp.write("Subject: %s\n" % form['subject'])
fp.write("%s\n" % form['Comments'])
fp.write("First Name: %s\n" % form['FirstName'])
fp.write("Last Name: %s\n\n" % form['LastName'])
print "Message sent"

def print_footer():
print "</BODY></HTML>"

def Main():
form = cgi.SvFormContentDict()
print_header()
disp_query (form)
print_footer()

Main()

Reply With Quote
  #2  
Old May 31st, 2004, 02:10 PM
ofricker ofricker is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 ofricker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi

I used the following code for redirection:

Code:
print "Content-Type: text/html"
        print
        print "<html>"
        print "<meta http-equiv=refresh content=0;url=/myurl.html>"
        print "</html>"   


Hope this helps
Oli

Reply With Quote
  #3  
Old June 1st, 2004, 08:54 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Depending on how you set your Page up you can use the Location header to redirect a user, as long as no other data has been outputed already

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Possible to Redirect to a URL???

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap