CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    May 2007
    Posts
    5

    Form Submit Works in IE not in Firefox?

    This is a contact form it works perfectly in IE, but not at all in fire fox, it goes into the process_contact function but doesn't come out. Thanks in advance, for the support.


    Code:
    <head>
    /////////////////////////////////////////////////////////////////////////////////////////////
    
    
    <script language="JavaScript" type="text/javascript">
    
    
    var receiveReq = getXmlHttpRequestObject();
    
    function getXmlHttpRequestObject()
    {
    try{
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    		return ajaxRequest;
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    			return ajaxRequest;
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    				return ajaxRequest;
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    }
    
    function process_contact() {
    
    receiveReq.open("GET", "contact.php", true);
    
    receiveReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    
    var email = document.getElementById('contact_email').value;
    
    var content = document.getElementById('contact_content').value;
    
    var filled = document.getElementById('contact_filled').value;
    
    receiveReq.onreadystatechange = handle_process_contact; 
    
    receiveReq.send('contact_email=' + email + '&contact_content=' + content + '&contact_filled=' + filled);
    
    }
    
    
    
    function handle_process_contact() {
    
    if (receiveReq.readyState == 4) {
    document.getElementById('span_result').innerHTML = receiveReq.responseText;
            }
    }
    			
    ////////////////////////////////////////////////////
    </script>
    </head>
    
    <body>
    
    <?
    //////////////////////////////////////////////////////
    //Begin contact.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 = "[email protected]";
    $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.";
    }
    }
    ?>
    <form action="#" method="post">
    <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"><a href="javascript: process_contact();"><img src="images/submit.gif" border="0" onclick="javascript: process_contact();" /></a></p>
    </form>
    
    </body>
    Last edited by madchops1; May 18th, 2007 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured