Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
  #16  
Old March 5th, 2004, 09:03 AM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)




Reply With Quote
  #17  
Old March 5th, 2004, 09:05 AM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry, it is Python 1.5 on the server.

Reply With Quote
  #18  
Old March 5th, 2004, 10:43 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 495 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 6 m 24 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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?

Reply With Quote
  #19  
Old March 5th, 2004, 10:51 AM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #20  
Old March 5th, 2004, 10:54 AM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 495 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 6 m 24 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
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.

Reply With Quote
  #21  
Old March 5th, 2004, 11:32 AM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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
Attached Files
File Type: txt demo.txt (12.4 KB, 123 views)

Last edited by brrrett : March 6th, 2004 at 09:02 PM. Reason: Update on problems

Reply With Quote
  #22  
Old July 6th, 2008, 08:31 PM
GuedoTech GuedoTech is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 GuedoTech User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 44 sec
Reputation Power: 0
Help

Brett, this is an old friend from Chicago, IL. I need your help with StoreMonitor.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > CGI form


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway