Jump to content

Recommended Posts

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.TacticalSolar.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.

Here is part of the code, which may help:

	$_SESSION['contactTF']='closed';
			$fields=array();
			$fields[]='<table border="0" cellpadding="1" cellspacing="1"><tr><td colspan="2" align="left"></td></tr>';
			$fields[]='<tr><td align="center"> </td><td align="left"><strong><u><font color="blue">-Contact Information-</font></u></strong></td></tr>';	 
			$fields[]='<tr><td align="right"><strong>Name:</strong></td><td>  ' . $fn.'  '.$ln.'</td></tr>';
			if($title) {$fields[]='<tr><td align="right"><strong>Title:</strong></td><td>  ' . $title.'</td></tr>';}
			$fields[]='<tr><td align="right"><strong>Company:</strong></td><td>  ' . $co.'</td></tr>';
			if($address){$fields[]='<tr><td align="right"><strong>Address:</strong></td><td>  ' . $address.'</td></tr>';}
			if($city) { $fields[]='<tr><td align="right"><strong>City:</strong></td><td>  ' . $city.'</td></tr>';}
			if($ct==0 || $ct==232){	
				$fields[]='<tr><td align="right"><strong>State:</strong></td><td>  ' . $sA[$st].'</td></tr>';	
			}else{
				if($prov) { $fields[]='<tr><td align="right"><strong>Province:</strong></td><td>  ' . $prov.'</td></tr>';}
			}	
			if($zip) { $fields[]='<tr><td align="right"><strong>Zip:</strong></td><td>  ' . $zip.'</td></tr>';}
			if($cA[$_SESSION['cntry']]) {$fields[]='<tr><td align="right"><strong>Country:</strong></td><td>  ' .$cA[$_SESSION['cntry']].'</td></tr>';}
			$fields[]='<tr><td align="right"><strong>Email address:</strong></td><td>  ' . $e.'</td></tr>';
			$fields[]='<tr><td align="right"><strong>Phone:</strong></td><td>  ' . $p.'</td></tr>';
			if($fax) { $fields[]='<tr><td align="right"><strong>Fax:</strong></td><td>  ' . $fax.'</td></tr>';}
			$fields[]='<tr><td align="right"><strong>From Website:</strong></td><td>  ' .$site.'</td></tr>';
			$fields[]='<tr><td align="right"><strong>Contact:</strong></td><td>  ' . $contactPerson.'</td></tr>';
			$fields[]='<tr><td align="right"><strong>Current Need:</strong></td><td>  ' . $rad.'</td></tr>';
			if($req) { $fields[]='<tr><td align="right" valign="top"><strong>Additional Requirements:</strong></td><td>  '
			.stripslashes($req).'</td></tr>';}
			if($prodcd) { $fields[]='<tr><td align="right" valign="top"><strong>Product CD:</strong></td><td>  Please mail a Product CD</td></tr>';}
			$fields[]='<tr><td align="right"> </td></tr>';
			$fields[]='<tr><td align="right"> </td></tr>';
			
			$_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 = "sale@tacticalpower.com"; 
			//$recipmail = "lb@ruggedsystems.com";
			//$recipmail = "dl@ruggedsystems.com";
			$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 ?? :(");
					}
				}
Edited by Graz73

the page you linked to has a ton of html and css errors and warnings (check at validator.w3.org) i even see an external javascript file being referenced before the <!DOCTYPE tag, meaning the the browsers cannot find the doctype and there are also several external javascript files being referenced twice. there's even a couple of form input fields that aren't within a form. you need to correct ALL of the html, css, and javacript problems first, since different browsers will behave differently when errors are present in the page you send them.

 

i also notice that the forms don't have any action='...' attribute. i don't know if you are submitting the forms using javscript or counting on a nonexistent action to submit to the same page, but in either case, the variation of the url may be changing (the host-name/subdomain), relative to the session id cookie, and this may be causing the code to not behave as expected.

 

 

The form does not always actually send the data to us when it says it does

 

 

what exact indication/output do you receive, in the case where it doesn't work? this would at least tell us what it is you see when you try it when it doesn't work, in order to narrow down some of the possibilities.

you are going to need to debug what your code IS doing in order to find out what is causing the problem. some value(s) are either not being set (given the number of html errors on the page, this is a possibility, the browsers it works in may be more forgiving of the errors) or are being set to an value that the code isn't expecting (different browsers send different things in the same situation that code needs to take into account.)

 

i did notice that the form is setting a hidden field, that hopefully is being tested in the php code to determine if the form has been submitted, so the php code should at least be able to detect that a form was submitted.

 

unless there's an obvious problem or a specific error message that points to the problem, there's isn't a single answer to  'Contact form not sending in IE or Safari'. you must track down what is happening to reduce the possibilities to just one or two that can be investigated further.

 

if your site receives a lot of visitors, it would be best if you logged all the data values that get submitted when the contact form is submitted, along with the browser's user agent string. you can then look at the logged data and determine why the code isn't doing what you expect it to do.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.