Page 1 of 1

contact form reload or refresh

Posted: Tue Apr 06, 2010 4:21 am
by mayapower
Hi,

This is my first post here and my skill sets are very limited in web programming domain.

I downloaded a free contact form php script which is working fine after uploading it to my site. When you press submit button and every thing is correct, it
shows thank you message.

I did couple of changes like when you press "Submit",
1. Show a message box with thanks message
2. clear all the fields
3. reload form so that, tags that have been colored as "RED" because of previous error again goes to black.

Here is the ripped version

Code: Select all

<?php
session_start();

$to = mymail@gmail.com';
OTHER VARIABLES ARE INITIALIZED HERE 

$thank_you_message = <<<EOD
<!-- Start message -->
<p>We have received your message. If required, we'll get back to you as soon as possible.</p><br /><br /><br /><br /><br /><br /><br /><br />
<!-- End message -->
EOD;

$thank_you_url = '';

if (!isset($_POST['submit'])) {

  showForm();

} else { //form submitted

  $error = 0;
CHECK FIELDS AND IF THEY ARE EMPTY
$error = 1;
  
  if ($error == 1) {
    $error_message = '<span style="font-weight:bold;font-size:90%;">Please correct/enter field(s) in red.</span>';
    showForm();


  } else {

  	SEND MAIL

    if (!$thank_you_url) {
	
      
           echo("<SCRIPT LANGUAGE='JavaScript'>
	 window.alert('We have received your message. If required, we'll get back to you as soon as possible.')
		</SCRIPT>");   
   /*error status false*/
    $error=0;
/* clear all the fields*/
    $name[2]="";
    $email[2]="";
    $message[2]="";
    $subject[2]="";
/* reload the form*/
    showForm();
    
   
	  }
	  else {
	  	header("Location: $thank_you_url");
	  }

  }

} //else submitted



function showForm()
{
GLOBAL VARS
include $header_file;
<form method="post" class="cForm">
ALL THE FIELDS INSIDE A TABLE
</form>
include $footer_file;
}

?>
Now this works only in the case if I directly access this form by it's URL. For example http://www.mysite\contact.php

What I need is to load this form in model window based on fancybox. The form is correctly getting loaded
in a model window but when i press submit button I get this error:

Code: Select all

Method Not Allowed
The requested method GET is not allowed for the URL /contact/index.html.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I also tried loading this form between "div" and pressing the "submit" button shows same error.

How do I solve this problem?

Regards

Prashant