Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Contact Form Not Working

Posted on 2014-12-01
3
123 Views
Last Modified: 2014-12-04
Can anyone tell me why this contact form is not sending the data. It never even gets to the success page when you submit it.

<?php

session_start();
if(strtoupper($_SESSION['keycode']) != strtoupper($_POST['r_captcha'])){
				$error .= "<span style='color:#FF0000'>The security code you entered '".$_POST['r_captcha']."' did not match the one 
							displayed '".$_SESSION['keycode']."'<br> please go back and try again.</span><br/><br/>";
}


//$to		= "my@gmail.com";
$to		= "me@gmail.com";
$from 	= $_POST['r_Email'];
$sub	= "Contact Form" ;

//  Validation of required field
foreach($_POST as $key=>$val){
	$rkey = explode('_',$key);
	 	if ($rkey[0]=='r'){			
			if($val==""){
				$nu++;
				$error .= $nu."- ". $rkey[1]."<br/>";				
			}
		}
}

// Redirect if requird field empty
if ($error!=""){
	include ('error-contact.htm');
}else{
	
$body .= 	"Name: ". 		$_POST['r_Name'].		"<br/>";
$body .= 	"Email: ". 	$_POST['r_Email'].	"<br/>";
$body .= 	"Phone: ". 	$_POST['r_Phone'].	"<br/><br/>";
$body .= 	"Appointment Details  "		"<br/>";
$body .= 	"Preferred Dates/Times: ".  		$_POST['r_Preferred_Dates_Times'].		"<br/>";
$body .= 	"Preferred Location: ".  		$_POST['r_Preferred_Location'].		"<br/>";
$body .= 	"Preferred Length: ".  		$_POST['r_Preferred_Length'].		"<br/>";
$body .= 	"Outcall Location: ".  		$_POST['outcall'].		"<br/>";
$body .= 	"Any Likes or Dislikes: ".  		$_POST['Any_Likes_or_Dislikes'].		"<br/>";
$body .= 	"Model(s) interested in:  ".  		$_POST['Model_interested_in'].		"<br/>";
$body .= 	"Comments: ".  		$_POST['message'].		"<br/>";



	 $headers  	= "MIME-Version: 1.0\r\n";
     $headers  .= "Content-type: text/html; charset=iso-8859-1\r\n";
   	 $headers 	= "From: $from\r\n";
	 $headers  .= "Content-type: text/html; charset=iso-8859-1 \n";	 	 
	 $rea = mail($to,$sub,$body, $headers);
	 
	 if ($ret){
	 	$ret="true";
		$error = "Sending Fail";
		include ('index.php');
	 }else{
	 	$ret="false";
		$error = "Thanks for contacting us<br />
Belle de Jour";
		include ('success-contact.htm');
	 }	 
	 print $ft[name];
} 
?>

Open in new window




HERE IS THE FORM

                  <form action="contact_mail.php" method="post" id="emailform">
                    <table border="0" cellspacing="0" cellpadding="0" align="center">
                      <tr> 
                        <td> <table border="0" cellspacing="0" cellpadding="0">
                            <tr> 
                              <td><span class="Estilo3">Name*</span></td>
                              <td><input type="text" name="r_Name"></td>
                            </tr>
                            <tr> 
                              <td><span class="Estilo3">Email*</span></td>
                              <td><input type="text" name="r_Email"></td>
                            </tr>
                            <tr> 
                              <td><span class="Estilo3">Phone*</span></td>
                              <td><input type="text" name="r_Phone"></td>
                            </tr>
                            <tr> 
                              <td><strong>Appointment Details </strong></td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr> 
                              <td>Preferred Dates/Times:* <br></td>
                              <td><input type="text" name="r_Preferred_Dates_Times"></td>
                            </tr>
                            <tr> 
                              <td>Preferred Location:* <br></td>
                              <td><input type="text" name="r_Preferred_Location"></td>
                            </tr>
                            <tr> 
                              <td>Preferred Length:* <br></td>
                              <td><input type="text" name="r_Preferred_Length"></td>
                            </tr>
                            <tr> 
                              <td>Outcall Location:<br></td>
                              <td><input type="text" name="outcall"></td>
                            </tr>
                            <tr> 
                              <td>Any Likes or Dislikes: <br></td>
                              <td><input type="text" name="Any_Likes_or_Dislikes"></td>
                            </tr>
                            <tr> 
                              <td>Model(s) interested in: </td>
                              <td><input type="text" name="Model_interested_in"></td>
                            </tr>
                            <tr> 
                              <td><span class="Estilo2 Estilo4 Estilo3">Comments:</span></td>
                              <td><textarea name="message"></textarea></td>
                            </tr>
                            <tr> 
                              <td align="right"><strong>Please enter the text 
                                as it is shown in the box below:<span class="style1">*</span></strong></td>
                              <td><input type="text" name="r_captcha" /></td>
                            </tr>
                            <tr> 
                              <td align="right">&nbsp;</td>
                              <td><img src="captcha.php" style="border: 1px solid silver;" alt="Captcha Image: you will need to recognize the text in it." title="Captcha Image: you will need to recognize the text in it." id="captcha" /></td>
                            </tr>
                            <tr> 
                              <td align="right">&nbsp;</td>
                              <td><input type="submit" name="Submit" value="Submit" /></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table>
                  </form>

Open in new window

0
Comment
Question by:smphil
3 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40474830
As a start. try it without the captcha.  That frequently is the source of problems.  

Look in the error logs to see what, if any messages you are getting.

Then step through the code and use var_dump at each step in verify that you have the values you expect. I would start by looking at the $_POST variables

If the $_POST variables are not coming across, then the problem is probably in the markup, and we will need a link so we can do diagnostics.

Cd&
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40474853
There were several errors in the $body part.
$body = 	"Name: ". 		$_POST['r_Name'].		"<br/>";
$body .= 	"Email: ". 	$_POST['r_Email'].	"<br/>";
$body .= 	"Phone: ". 	$_POST['r_Phone'].	"<br/><br/>";
$body .= 	"Appointment Details  <br/>";
$body .= 	"Preferred Dates/Times: ".  		$_POST['r_Preferred_Dates_Times'].		"<br/>";
$body .= 	"Preferred Location: ".  		$_POST['r_Preferred_Location'].		"<br/>";
$body .= 	"Preferred Length: ".  		$_POST['r_Preferred_Length'].		"<br/>";
$body .= 	"Outcall Location: ".  		$_POST['outcall'].		"<br/>";
$body .= 	"Any Likes or Dislikes: ".  		$_POST['Any_Likes_or_Dislikes'].		"<br/>";
$body .= 	"Model(s) interested in:  ".  		$_POST['Model_interested_in'].		"<br/>";
$body .= 	"Comments: ".  		$_POST['message'].		"<br/>";

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 40474923
Add some error reporting at the top of the page and these errors will be evident

<?php
error_reporting(E_ALL);
...

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Currency in SQL? 2 30
what do I need to host my own web sites? 13 50
ability to create nested list on the UI using PHP, HTML, Javascript 7 43
Log in through ID 5 17
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question