|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 "<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() |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Possible to Redirect to a URL??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|