mvchandoo 0 Newbie Poster

Hi,
The form consists captcha and it is validating well. After validation the form is not submitting. do any one help me. as it was a urgent task.thank you in advance.

<form name="contact_us" id="contact_us" method="post" action="feedform_mail.php" onSubmit="check(); return false;" enctype="multipart/form-data">
	  <input TYPE="hidden" NAME="recipient" VALUE="formmail@bodyrotic.com.au">
      <input type="hidden" name="missing_fields_redirect" value="http://www.bodyrotic.com.au/pages/feedback/feederror.htm">
      <input TYPE="hidden" NAME="subject" VALUE="BODYROTIC feedback form">
	  <table width="98%" border="0" cellpadding="5" cellspacing="1">
  <tr>
    <td width="40%" align="right"><font color="#FF9933"> name : </font></td>
    <td width="60%" align="left"><font color="#FF9933">
      <input name="realname" size="22"></font></td>
  </tr>
  <tr>
    <td align="right"><font color="#FF9933"> email address : </font></td>
    <td align="left"><font color="#FF9933">
      <input type="text" name="email" size="22"></font></td>
  </tr>
  <tr>
    <td align="right"><font color="#FF9933"> question or comments... : </font></td>
    <td align="left"><font color="#FF9933">
      <textarea cols="40" rows="9" name="user_comment"></textarea>
    </font></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td align="left"><font color="#FF9933">
      <p class="captcha">
        <!--<div id="captchaimage"><a href="<?php echo $_SERVER['PHP_SELF']; ?>" onclick="refreshimg(); return false;" title="Click to refresh image"><img src="images/image.jpg?<?php echo time(); ?>" width="132" height="46" alt="Captcha image" /></a><div id="refreshmsg">If you cannot crack the captcha, click on the image once to reload a new one.</div></div>-->
        <img src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>" id="image"><br />
        <a href="#" onClick="document.getElementById('image').src = 'securimage_show.php?sid=' + Math.random(); return false">Reload Image</a><br>
      </p>
    </font></td>
  </tr>
  <tr>
    <td align="right"><font color="#FF9933">Captcha : </font></td>
    <td align="left"><font color="#FF9933">
      <input type="text" maxlength="6" name="captcha" id="captcha" />
    <div id="captchaerror"></div>
    </font></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td align="left">
	<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADR,REMOTE_USER,HTTP_USER_AGENT,HTTP_REFERER">
      <input type="hidden" name="redirect" value="http://www.bodyrotic.com.au/pages/feedback/thankyou.htm">
      <br>
      <input name="submit" type="submit" value="send">
      <font color="#999999">&nbsp;&nbsp;<br>
(we will 
      do our best to respond to questions within 24 hours)</font></td>
  </tr>
</table>
</form>

and the js is 
// CREATING THE REQUEST

function createRequestObject()
{
	try
	{
		xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		alert('Sorry, but your browser doesn\'t support XMLHttpRequest.');
	}
	return xmlhttp;
}

var http = createRequestObject();
var sess = createRequestObject();

// IMAGE REFRESHING

function refreshimg()
{
	var url = 'includes/image_req.php';
	dorefresh(url, displayimg);
}

function dorefresh(url, callback)
{
	sess.open('POST', 'includes/newsession.php', true);
	sess.send(null);
	http.open('POST', url, true);
	http.onreadystatechange = displayimg;
	http.send(null);
}

function displayimg()
{
	if(http.readyState == 4)
	{
		var showimage = http.responseText;
		document.getElementById('captchaimage').innerHTML = showimage;
	}
}

// SUBMISSION

function check()
{
	if(!validation())
	  {
		return false; 
		  }
	var submission = document.getElementById('captcha').value;
	var url = 'check_captcha.php?captcha=' + submission;
	docheck(url, displaycheck);
}

function docheck(url, callback)
{
	http.open('GET', url, true);
	http.onreadystatechange = displaycheck;
	http.send(null);
}

/*//SUBMIT THE FORM, IF THE CAPTCHA IS CORRECT
function submitform(){
var name = document.getElementById("contact_name").value;
var email = document.getElementById("contact_email").value;
var subject = document.getElementById("contact_phone").value;
var msg = document.getElementById("contact_comments").value;
document.getElementById('loading').style.display = 'block';
document.contact_us.submit.disabled = 'true'; //DISABLE THE SUBMIT BUTTON
http.open('GET', 'includes/mailer.php?name=' +name +'&subject=' +subject +'&email=' +email+ '&msg='+escape(msg)); 
	http.onreadystatechange = printit;
	http.send(null);

}
//PRINT THE RESPONSE FROM PHP
function printit()
{
	if(http.readyState == 4)
	{
	
	document.getElementById('loading').style.display = 'none';
	document.getElementById('results').innerHTML = http.responseText; //PRINT THE PHP'S RESPONSE IN THE RESULTS DIV
	}
}*/	
function displaycheck()
{
	if(http.readyState == 4)
	{
		var showcheck = http.responseText;
		//alert(showcheck);
		if(showcheck == '1') //CAPTCHA IS CORRECT
		{
			document.getElementById('captcha').style.border = '1px solid #49c24f';
			document.getElementById('captcha').style.background = '#bcffbf';
			document.getElementById('captchaerror').innerHTML = '';			
			document.contact_us.action='feedform_mail.php';	
			return true;
			document.getElementById('contact_us').submit();
			document.contact_us.submit();
			
			alert('test');
			
			//submitform(); //SUBMIT THE FORM
		}
		if(showcheck == '0')
		{
			document.getElementById('captcha').style.border = '1px solid #c24949';
			document.getElementById('captcha').style.background = '#ffbcbc';
			document.contact_us.captcha.value = ''; //RESET THE CAPTCHA INPUT'S VALUE
			document.contact_us.captcha.focus(); //CHANGE THE FOCUS TO CAPTCHA INPUT
			document.getElementById('captchaerror').innerHTML = '<font color="#c24949"><b>Please Re-enter the CAPTCHA</b></font>';
		}
	}
}

// JavaScript Document
/*function validation() 
{
if(document.contact_us.contact_name.value=="") 
{
alert("Please enter the Name");
document.contact_us.contact_name.focus();
return false;
}
if(document.contact_us.contact_email.value=="")
{
alert("Please enter the Email");
document.contact_us.contact_email.value="";
document.contact_us.contact_email.focus();
return false;
}
if(!echeck(document.contact_us.contact_email.value))
{
document.contact_us.contact_email.value="";
document.contact_us.contact_email.focus();
return false;
}
if(document.contact_us.contact_phone.value=="")
{
alert("Please enter the Phone Number");
document.contact_us.contact_phone.value="";
document.contact_us.contact_phone.focus();
return false;
}
else if(document.contact_us.contact_phone.value!="")
{
	if(isNaN(document.contact_us.contact_phone.value))
	{
	alert("Only Numbers for Phone");
	document.contact_us.contact_phone.value="";
	document.contact_us.contact_phone.focus();
	return false; 
	}
}
if(document.contact_us.contact_comments.value=="" || document.contact_us.contact_comments.value=="Enter your query here...") 
{
alert("Please enter the Comments");
document.contact_us.contact_comments.focus();
return false;
}
return true;
}
function echeck(Email)  
{
var at=Email.indexOf('@');
var dot=Email.lastIndexOf('.');
var atpos=Email.lastIndexOf('@');
var emlen=Email.length;
if (at<1||dot-at<2||atpos+1==emlen||dot+1==emlen||emlen-dot<3) 
{
alert('invalid the Email Address');
return false;
}
return true;
} */

function validation() 
{
if(document.contact_us.realname.value=="") 
{
alert("Please enter the Name");
document.contact_us.realname.focus();
return false;
}
if(document.contact_us.email.value=="")
{
alert("Please enter the Email");
document.contact_us.email.value="";
document.contact_us.email.focus();
return false;
}
if(!echeck(document.contact_us.email.value))
{
document.contact_us.email.value="";
document.contact_us.email.focus();
return false;
}

return true;
}
function echeck(Email)  
{
var at=Email.indexOf('@');
var dot=Email.lastIndexOf('.');
var atpos=Email.lastIndexOf('@');
var emlen=Email.length;
if (at<1||dot-at<2||atpos+1==emlen||dot+1==emlen||emlen-dot<3) 
{
alert('invalid the Email Address');
return false;
}
return true;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.