
May 31st, 2004, 01:50 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
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()
|