|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Sorry about my last explanation, I use TAB's only. The only way I can get rid of the error so far is to Take Out the Mail Code.
I posted it to the web to see what would happen and the Error Log says "Premature end of script Headers". Python 1.2 is on my server. Here is the mail code just in case I am missing something. Code:
def mail(address, subject, message, host = 'mail.haystar.com'):
message = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' % (address[0], ','.join(address[1:], subject, message)
server = smtplib.SMTP('haystar.com')
server.sendmail(address[0], address[1:], message)
server.quit()
message = name\n + address\n + city\n + state\n + zip\n + phone\n + register\n + email
address = Online Demo Request Page, demo@haystar.com
subject = Online Demo Request
mail(address, subject, message)
![]() |
|
#17
|
|||
|
|||
|
Sorry, it is Python 1.5 on the server.
|
|
#18
|
|||
|
|||
|
brrrett, what are you doing with that version? You should always have the latest version of Python.
http://www.python.org/download/ Once you update your version, test the script. Tell us how it goes. Could you post the exact code that you're testing, so that others can test it too? |
|
#19
|
|||
|
|||
|
OK. I have the latest Python on my pc, but my web server has Python 1.5 on it.(imagelinkusa.net)
I figured out the code(I think) When I run Check Module I get NO ERRORS. I made smo new functions to help the flow. This has seem to work. Inspite of that I am still getting "Internal Server Error" on the site. The error log says: "Premature end of script headers" Here is the code: Code:
#!/usr/lib/python
import cgi
from urllib import quote_plus
header = 'Content-Type: text/html\n\n'
url = '/cgi-bin/demreq.py'
errhtml = '''<HTML><HEAD><TITLE>
StoreMonitor Demo Request Form</TITLE></HEAD>
<BODY><H3>ERROR</H3>
<B>%s</B><P>
<FORM><INPUT TYPE=button VALUE=Close
ONCLICK="window.close()"></FORM>
</BODY></HTML>'''
def success(thankyou):
thankyou = 'Your message has been received, thank you for\n your submittion. You may close this window.'
print thankyou
def showError(error_str):
print header + errhtml % (error_str)
def composemessage(message):
message = name+address+city+state+zip+phone+register+email
address = 'Online Demo Request Page', 'demo@haystar.com'
subject = 'Online Demo Request'
mail(address, subject, message)
def mail(address, subject, message, host = 'mail.haystar.com'):
message = 'Subject: %s\r\n\r\n%s' % (subject, message)
import smtplib
try:
server = smtplib.SMTP(host)
server.sendmail(address[0], address[1:], message)
server.quit()
success()
except error:
showError('Mail not sent!')
def process():
form = cgi.FieldStorage()
try:
if form.has_key("name"):
name = form["name"].value
if not error:
showError('A name must be provided!')
if form.has_key("comp"):
comp = form["comp"].value
if not error:
showError('A Company must be provided!')
if form.has_key("address"):
address = form["address"].value
if not error:
showError('An Address must be provided!')
if form.has_key("city"):
city = form["city"].value
if not error:
showError('A City must be provided!')
if form.has_key("state"):
state = form["state"].value
if not error:
showError('A state must be provided!')
if form.has_key("zip"):
zip = form["zip"].value
if not error:
showError('A Zipcode must be provided!')
if form.has_key("phone"):
phone = form["phone"].value
if not error:
showError('A phone # must be provided!')
if form["register"].value != 'Select One':
register = form["register"].value
if not error:
showError('A register type must be provided!')
if form.has_key("email"):
email = form["email"].value
if not error:
showError('An email address must be provided!')
composemessage()
except error:
showError("Fatal Error, Form may be incomplete.")
if __name__ == '__main__':
process()
Any suggestions or do you think my web server needs to be updated? Thanks, Brett |
|
#20
|
|||
|
|||
|
Your Web server definitely needs to be updated. My Web server is using mod_python/3.1.2b and Python/2.3.3.
I'll test you script on my Web server, and I will tell you what happens. EDIT: I didn't receive any errors, except nothing appeared on the screen. Last edited by MasterChief : March 5th, 2004 at 11:00 AM. |
|
#21
|
|||
|
|||
|
Guys,
I think the problem is the enterpretuer(sp) on the server is not being envoked. If I call the Python script it displays it like a text file. Well, here take a look: http://www.haystar.com/scgi-bin/demreq.py What do you think. Thanks, Brett Last edited by brrrett : March 6th, 2004 at 09:02 PM. Reason: Update on problems |
|
#22
|
|||
|
|||
|
Help
Brett, this is an old friend from Chicago, IL. I need your help with StoreMonitor.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > CGI form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|