madchops1
May 22nd, 2007, 02:51 AM
This simple contact form works fine in IE but does not in FF. I cannot figure it out.
The form does return false, and the variables make it into the url, but in firefox nothing else happens. It is as if the file is not being called, but the javascript is in firefox????? Please help if you can.
Here is the javascript and the form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function process_contact() {
var oForm = document.forms[0];
var oXmlHttp = zXmlHttp.createRequest();
oXmlHttp.open("POST",'process_contact.php', true);
var email = document.getElementById('contact_email').value;
var content = document.getElementById('contact_content').value;
var filled = document.getElementById('contact_filled').value;
oXmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
//Set the function that will be called when the XmlHttpRequest objects state changes.
oXmlHttp.onreadystatechange = function () {
if (oXmlHttp.readyState == 4) {
if (oXmlHttp.status == 200) {
document.getElementById('span_result').innerHTML = oXmlHttp.responseText;
} else {
document.getElementById('span_result').innerHTML = "ERROR"
}
}
};
oXmlHttp.send('contact_email=' + email + '&contact_content=' + content + '&contact_filled=' + filled);
}
</script>
</head>
<body>
<span id="span_result"></span>
<div id="text">
<form action="" method="post" onsubmit="javascript:process_contact(); return false">
<!--<form method="post" action="" onsubmit="">-->
<p>
<label>*Email</label>
<input name="contact_email" type="text" value="<? echo"$contact_email";?>" />
</p>
<p>
<label>*Message</label><br />
<textarea name="contact_content" id="contact_content" cols="30" rows="10"><? echo"$contact_content";?></textarea>
</p>
<input type="hidden" name="contact_filled" id="contact_filled" value="filled" />
<p align="center">
<input type="submit" value="submit" />
</p>
</form>
</div>
</body>
</html>
<!-- END JAVASCRIPT AND FORM -->
///////////////////////////////////////////////////////////////////
This is the .php file that should process the form
<?
include'functions.php';
$contact_filled = $_REQUEST['contact_filled'];
if($contact_filled == "filled"){
$contact_email = $_REQUEST['contact_email'];
$contact_content = $_REQUEST['contact_content'];
if($contact_email == "" or $contact_content == ""){
$report = "Please fill in all *required fields.";
} else {
$insert = "INSERT INTO email SET
email_id = '',
email = '$contact_email'
";
$resres = mysql_query($insert) or die ("err 12154587.023265");
$to = "madchops11@yahoo.com";
$subj = "(KarlSteltenpohl.com Contact Message)";
$head = "From: $contact_email <$contact_email>";
$mess = "
$contact_content
";
@mail($to, $subj, $mess, $head, $add) or die("Help Email Failed");
$report = "Contact Message Sent. Thank You.";
}
report($report);
} else { echo"Filled not Filled."; }
?>
The form does return false, and the variables make it into the url, but in firefox nothing else happens. It is as if the file is not being called, but the javascript is in firefox????? Please help if you can.
Here is the javascript and the form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function process_contact() {
var oForm = document.forms[0];
var oXmlHttp = zXmlHttp.createRequest();
oXmlHttp.open("POST",'process_contact.php', true);
var email = document.getElementById('contact_email').value;
var content = document.getElementById('contact_content').value;
var filled = document.getElementById('contact_filled').value;
oXmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
//Set the function that will be called when the XmlHttpRequest objects state changes.
oXmlHttp.onreadystatechange = function () {
if (oXmlHttp.readyState == 4) {
if (oXmlHttp.status == 200) {
document.getElementById('span_result').innerHTML = oXmlHttp.responseText;
} else {
document.getElementById('span_result').innerHTML = "ERROR"
}
}
};
oXmlHttp.send('contact_email=' + email + '&contact_content=' + content + '&contact_filled=' + filled);
}
</script>
</head>
<body>
<span id="span_result"></span>
<div id="text">
<form action="" method="post" onsubmit="javascript:process_contact(); return false">
<!--<form method="post" action="" onsubmit="">-->
<p>
<label>*Email</label>
<input name="contact_email" type="text" value="<? echo"$contact_email";?>" />
</p>
<p>
<label>*Message</label><br />
<textarea name="contact_content" id="contact_content" cols="30" rows="10"><? echo"$contact_content";?></textarea>
</p>
<input type="hidden" name="contact_filled" id="contact_filled" value="filled" />
<p align="center">
<input type="submit" value="submit" />
</p>
</form>
</div>
</body>
</html>
<!-- END JAVASCRIPT AND FORM -->
///////////////////////////////////////////////////////////////////
This is the .php file that should process the form
<?
include'functions.php';
$contact_filled = $_REQUEST['contact_filled'];
if($contact_filled == "filled"){
$contact_email = $_REQUEST['contact_email'];
$contact_content = $_REQUEST['contact_content'];
if($contact_email == "" or $contact_content == ""){
$report = "Please fill in all *required fields.";
} else {
$insert = "INSERT INTO email SET
email_id = '',
email = '$contact_email'
";
$resres = mysql_query($insert) or die ("err 12154587.023265");
$to = "madchops11@yahoo.com";
$subj = "(KarlSteltenpohl.com Contact Message)";
$head = "From: $contact_email <$contact_email>";
$mess = "
$contact_content
";
@mail($to, $subj, $mess, $head, $add) or die("Help Email Failed");
$report = "Contact Message Sent. Thank You.";
}
report($report);
} else { echo"Filled not Filled."; }
?>