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 <br /><br />
for the Plain Community.<br /><br />
</div><!-- end of sideBar div -->
<div id="rightBox"><br /><br /><br /><br />
<h1>Thank you for submitting this site:</h1>
<br />
http://www.google.com/search?hl=en&client=firefox-a&hs=OgF&rls=org.mozilla%3Aen-US%3Aofficial&q=funny+jokes&aq=f&aqi=g-p1g9&aql=&oq=&gs_rfai=
<br>
<br>
Phrase 1 not supplied
<br>
<br>
Phrase 2 not supplied
<br>
<br>
</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>