Stumped on PHP Contact Form Bug

Please help:
I’m trying to figure out what is going on with a custom made PHP contact form on my company’s multiple websites.
Check it out here: www dot TacticalSolar dot com

This custom form was made by a former employee and USUALLY works great. Validation, spam checking, database connection, etc. But I’ve discovered a bug. The form does not always actually send the data to us when it says it does! This problem almost always happens in Internet Explorer and Safari browsers. But sometimes that data shows up. This does not effect Firefox or Chrome.

I’ve been looking everywhere, but no idea what is causing this. Thoughts? Ideas?
I’m no PHP coder so even obvious places to look are welcome.

Are you looking to try to fix this yourself, or are you looking to farm it out? Without seeing code, there is no way to determine what is or is not happening. First place to look is at whatever page the contact form submits to. Beyond that, it is only speculation.

Thanks Astonecipher, Look and see if this helps:

[php] $_SESSION[‘contactTF’]=‘closed’;
$fields=array();
$fields[]=’

’;
$fields[]=’’;
$fields[]=‘’;
if($title) {$fields[]=‘’;}
$fields[]=‘’;
if($address){$fields[]=‘’;}
if($city) { $fields[]=‘’;}
if($ct==0 || $ct==232){
$fields[]=‘’;
}else{
if($prov) { $fields[]=‘’;}
}
if($zip) { $fields[]=‘’;}
if($cA[$_SESSION[‘cntry’]]) {$fields[]=‘’;}
$fields[]=‘’;
$fields[]=‘’;
if($fax) { $fields[]=‘’;}
$fields[]=‘’;
$fields[]=‘’;
$fields[]=‘’;
if($req) { $fields[]=‘’;}
if($prodcd) { $fields[]=‘’;}
$fields[]=’‘;
$fields[]=’';
		$_SESSION['spamemail']='<div style="font-size:10px; color:#FF0000;">
		The email address provided did not pass the DNS check. This is most likely a spam email.<br />
		From IP: '.$_SERVER['REMOTE_ADDR'].'  Host: '.gethostbyaddr($_SERVER['REMOTE_ADDR']);
		if ($nvEmail=='true' || $posSpam > 1){
			if($nvEmail=='true') {
				$fields[]='<tr><td align="right" valign="top" style="font-size:11px; color:#FF0000;">
				<strong>Spam Warning:</strong></td><td>' . $_SESSION['spamemail'].'</td></tr>';
			}
			if($posSpam > 1) {
				$fields[]='<tr><td align="right" valign="top" style="font-size:10px; color:#FF0000;">
				<strong>Spam Warning:</strong></td><td style="font-size:11px; color:#FF0000;">Total spam flags detected '.$posSpam.'</td></tr>';
			}
		}
		$fields[]='</table>';
		$msg=""; 

		$recipmail = "[email protected]"; 
		//$recipmail = "[email protected]";
		//$recipmail = "[email protected]";
		$emailmsg = '
		<html>
		<head>
			<title>Contact Form</title>
			
			<link href="contact.css" rel="stylesheet" type="text/css" />
			<style>
				.BoxBorder {
				padding: 3px 3px 3px 3px;
				border: 1px solid  #C0CFE0;
				font-family:Arial, Helvetica, sans-serif;
				font-size:12px;
				color:#000000;}
				.emailstyle {
					font-size:10px;
					color:red;
				}
			</style>
		</head>
		<body> 
			<div class="BoxBorder">
			
			<table>
			<tr>
			<td>';
				 for ($j=0; $j<count($fields); $j++) { 
					 $emailmsg .= stripslashes($fields[$j]);
				}  $emailmsg .= '</td>
			</tr>
		</table>
		</div>
			</body>
		</html>';

			$name= $fn . ' ' . $ln;
			$subject = $_POST['formname'];
			if($subject=='/index.php') {
				$subject="";
				$subject='Request from home page';
			}else{
				$subject = explode('/',$subject);
				$subject = $subject[count($subject)-1];
				$subject = substr($subject,0,-4);
				$subject = str_replace('_',' ',$subject);
				$page=$subject;
				$subject = strtoupper($subject);
			}
			$subsite = $_SERVER['SERVER_NAME'];
			$subsite = explode('www.',$subsite);
			$subsite = $subsite[count($subsite)-1];
			$subsite = substr($subsite,0);
			$subsite = str_replace('_',' ',$subsite);
			$subsite = ucfirst($subsite);
			$webproduct = $subject;
			$subject = 'Product Info Request-'.$subsite.': '. $subject;
			$mailsubj = $subject;
			
			if ($nvEmail=='true' || $posSpam > 0) {
				$from='Possible Spam E-mail \('.$email.'\)';
			}else{
				$from = $e;
				$from = urldecode($from);
				if (eregi("(\r|\n)", $from)) {
				  die("Why ?? :(");
				}
			}[/php]
  -Contact Information-
Name:   ’ . $fn.’ ‘.$ln.’
Title:   ’ . $title.’
Company:   ’ . $co.’
Address:   ’ . $address.’
City:   ’ . $city.’
State:   ’ . $sA[$st].’
Province:   ’ . $prov.’
Zip:   ’ . $zip.’
Country:   ’ .$cA[$_SESSION[‘cntry’]].’
Email address:   ’ . $e.’
Phone:   ’ . $p.’
Fax:   ’ . $fax.’
From Website:   ’ .$site.’
Contact:   ’ . $contactPerson.’
Current Need:   ’ . $rad.’
Additional Requirements:   ’
.stripslashes($req).’
Product CD:   Please mail a Product CD
 
 

Haven’t really lokoed into this - but from looking over it - i know quite a few have an issue with getting customers ip addresses - Maybe try this?

Also - we had a few issues with sessions on some of our servers - whilst it works for 90% of the customers - we have to use a cookie version due to some sessions randomly dropping mid process…

Also have you tried just using inline stylesheets rather than relative attachements?

Also its got alot of spam detection… but what does it do with it?

Thanks guys.
Lewis: I could drop that IP function if it might be causing problems, and I’m not sure why it was programmed with sessions or relative stylesheets.

The spam detection just adds a message to the bottom of the submitted form saying “possible spam” if it does not pass the checks. Our general manager didnt want us to risk loosing any leads.

WOW! That is just all sorts of wrong. I have to say, your “former” employee didn’t know what the hell he was doing. I would trash that whole thing and start fresh. I can build you a new form for a reasonable fee. Someone may help you fix what you have, but they really shouldn’t.

The entire site is very poorly coded and full of errors on every single page as well.

Graz - personally i would take kevin up on his offer lol. It looks qutie a mess - and looks like it was built by someone who took code from a million places and just shoved it in… Also - if you are working in a company with a few employees, he should have been adding some comments in there… out of courtesy for the other programmers.

Lewis: I could drop that IP function if it might be causing problems, and I'm not sure why it was programmed with sessions or relative stylesheets.
What id suggest is stripping it back to basic... then adding a little bit in, piece by peice.
The spam detection just adds a message to the bottom of the submitted form saying "possible spam" if it does not pass the checks. Our general manager didnt want us to risk loosing any leads.
Spam filters on servers do this quite well? Although you may have issues, if you are flagging up as spam, and the server flags the alteration you make as spam.. it would run it spam rule, even if its not - they do use quite a complex spam filtering system which validates the emails..

I’ve been doing the content/graphics for this site, but not the coding (except some promotional text or tables). Without the coding guy, I’m left to figure out what he was trying to do. He did comment SOME things, but most of it is just a ball of code that I’m trying to unwind.

I am working on a new contact form, while trying to solve this problem. But I’ll still have to get it integrated with his database sooner or later, which will put me back into messing with his code again. (So at that point then maybe I"ll hire one of you)

The spam filtering is mainly to look for bots that are trying to fill out the form. We didn’t want a captcha on there, so instead, we just made sure the email looked legit and there were no obviously spammy phrases in the messages.

Thats fine, but you need a good grasp of what you are doing with the code - especially to not reject legitamate applications. My advise is start with a basic mail function… then build from that…

[php]
$to = $email_address;

$subject = ‘Customer Application’;

$headers = “From: [email protected]\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html\r\n”;

$form_body = “

Hello

”;

mail($to, $subject, $form_body, $headers);

[/php]

After that you can add validation statement around that code… If you are unsure with things like this, you can either comment it or include it… so that it keeps it seperate to the code which you add.

Also, headers can be dependant on what data you are trying to process, thats just some from an html mail application.

This capcha thing looks nice if you wanted to use that…
http://www.abeautifulsite.net/a-simple-php-captcha-script/

Thanks Lewis. I’ll check out ALL that stuff.

The reason this is all bothering me is we’ve got this flawed contact form being called on 30 websites. Sites that are currently NOT getting the contacts sent in from IE or Safari. We are loosing sales, and not getting those people in our database.

I’ve already put together a little test form, www.mypowerstore.com but it is not close to being ready to replace this other one. So either I make a stripped down form that does very little and build it up, or I use the current flawed form.

Not the situation I like to be in! :frowning:

Np, just don’t let that other guy do a contact form again lol :stuck_out_tongue:

Sponsor our Newsletter | Privacy Policy | Terms of Service