954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

CGI output renders in IE but not Firefox

Hi everyone! My first post on daniweb, although I've often been helped by reading. :)

I have a CGI script that is driving me batty. CGI is in python. If I put any python code ABOVE the HTML printout of the script except for import statements & varable assignments, Firefox outputs the plain text rather than rendering the page. The page renders in IE just fine, however.

Summary: If I keep my python code to setting variables from the form plus import statements such as shown below, all is well in Firefox.

#!/usr/bin/python
import cgi, smtplib, sys
import sap_companydata, sap_admindata, sap_mailserverdata
import cgitb; cgitb.enable()

site_submit_form = cgi.FieldStorage()
site = cgi.escape(site_submit_form.getfirst('submit_url', 'Form error, no URL provided'))
reason = cgi.escape(site_submit_form.getfirst('submit_reasons', 'Form error, no Reason given'))
reasongiven = cgi.escape(site_submit_form.getfirst('submit_reasongiven', 'Form error, no polite reason given'))
categories = cgi.escape(site_submit_form.getfirst('submit_categories', 'N/A'))
comments = cgi.escape(site_submit_form.getfirst('comments', 'No comments submitted'))
ip = cgi.escape(site_submit_form.getfirst('submit_ip', 'IP address not supplied'))
cp1 = cgi.escape(site_submit_form.getfirst('confirmphrase1', 'Phrase 1 not supplied'))
cp2 = cgi.escape(site_submit_form.getfirst('confirmphrase2', 'Phrase 2 not supplied'))


Put just one simple if/elif statement there, however, and kablooey. Firefox just shows html text instead of rendering the page.

if cp1 == cp2:
    verify = 'True'
elif cp1 != cp2:
    verify = 'False'


Here is the HTML that Firefox displays. I'm pretty sure the HTML is ok. But what doesn't the page render?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Security Appliance</title>
<link href="../../public/CSS/Main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<table id="tablewrapper" width="100%" border="0" align="center">
  <tr>
    <td>
    <div align="center">
    <div id="wrapper">
      <div id="sideBar">
      <img src="../../public/images/sa_logo.jpg" width="200" height="278" alt="Security Appliance Logo" />
      Content filtering by and 
for the Plain Community.

  	  </div><!-- end of sideBar div -->
		<div id="rightBox">
        
        <h1>Thank you for submitting this site:</h1>


http://www.google.com/search?hl=en&amp;client=firefox-a&amp;hs=OgF&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;q=funny+jokes&amp;aq=f&amp;aqi=g-p1g9&amp;aql=&amp;oq=&amp;gs_rfai=


Phrase 1 not supplied


Phrase 2 not supplied


		</div>
<!-- end of rightBox div -->
	<div id="footer">
<table id="tablefooter" width="100%" border="0">
  <tr>
    <td width="48%">
      <div align="left" class="footer_copyright">Thank you for being a user.</div></td>
    <td width="52%"><p class="footer_phone">123-654-5335</p></td>
  </tr>
</table>
</div>
	<!-- end of footer div -->
</div>
</div> <!-- end of center div --></td>
  </tr>
</table>
</body>
</html>
thinkwell
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: