Page 1 of 1

Contact Script Errors

Posted: Sat Feb 19, 2005 10:43 pm
by brett2
Hi guys. I am working to get a new type of contact system working for my customer. What I have so far is the form, the actual error checking (basic stuff) and the mail. Here's what happens:

I enter the website, and input all the required info (everything) and hit Send. The page does its thing, and then spits out my thank-you page (as expected). Later I don't get an email message in my inbox.

Code: Select all

if($_REQUESTї'contact'] == 'send'){
		$breaks = array("\r", "\n", "\r\n", "<br>", "<br />");
		$Email = $_REQUEST&#1111;'email'];
		$Comments = $_REQUEST&#1111;'comments'];
		$Name = $_REQUEST&#1111;'fullname'];
		$Recip = $_REQUEST&#1111;'recip'];
		$Subject = '&#1111;RSC] '.eregi_replace($breaks, " ", $_REQUEST&#1111;'subject']);
		$Today = date("l F d, Y");
		$Time = date("g:i A");

		if(empty($Email))&#123;
			$_REQUEST&#1111;'ec'] = '1';
		&#125;
		else if(empty($Name))&#123;
			$_REQUEST&#1111;'ec'] = '2';
		&#125;
		else if(empty($Recip))&#123;
			$_REQUEST&#1111;'ec'] = '3';
		&#125;
		else if(empty($Subject))&#123;
			$_REQUEST&#1111;'ec'] = '4';
		&#125;
		else if(empty($Comments))&#123;
			$_REQUEST&#1111;'ec'] = '5';
		&#125;
		else&#123;
			$comments = wordwrap($Comments, 70);
			$headers = "From: ".$Name." "."<".$Email.">";
			$MessageHeader ="This is an email from the Ridge Swim Club Website.\n\n
							This message was sent by:\n
							Name:\t$Name\n
							Email:\t$Email\n\n";
			$MessageBody =	">========== Message ==========<\n\n
							$comments\n\n
							>========== End Message ==========<\n";
			$MessageFooter = "Message sent on: $Today at $Time.";
			$WholeMessage = "$MessageHeader $MessageBody $MessageFooter";

			$Message = eregi_replace($breaks, "\n", $WholeMessage);
			$message = stripslashes($Message);
			$mailed = mail($Recip, $Subject, $message, $headers);
			if($mailed === 'true')&#123;
				$_REQUEST&#1111;'pageid'] = '22';
			&#125;
			else&#123;
				$_REQUEST&#1111;'pageid'] = '23';
			&#125;
		&#125;
	&#125;

Code: Select all

<form name='contactForm' method='POST' >
<input type='hidden' name='contact' value='send' />
<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
<tr>
  <td valign='top' align='right'><b>Recipient:</b></td>
  <td align='left'>
	<select name='recip' id='recip'>
	  <option selected>Please choose from Below</option>
	  <optgroup label='Board Members'>
		  <option value='*********@********.com'>President</option>
		  <option Value='*********@********.com'>Vice President</option>
		  <option value='*********@********.com'>Membership</option>
	  </optgroup>
	  <optgroup label='Administrative'>
		  <option value=''>Pool Manager - COMING SOON</option>
		  <option value=''>Pool Manager - COMING SOON</option>
		  <option value='*********@********.com'>Webmaster</option>
	  </optgroup>
	</select></td>
</tr>
<tr>
<td valign='top' align='right'>Your Name:</td>
  <td align='left'>
    <input name='fullname' type='text' value='Your Full Name' size='40' onfocus='if(this.value=='Your Full Name') value=''' />
  </td>
</tr>
<tr>
  <td valign='top' align='right'>Your Email Address: </td>
  <td align='left'>
	<input name='email' type='text' value='Your Email' size='40' onFocus='if(this.value=='Your Email') value='''>
  </td>
</tr>
<tr>
  <td valign='top' align='right'>Subject of Email:</td>
  <td align='left'>
	<input name='subject' type='text' value='Subject of the Email' size='40' onFocus='if(this.value=='Subject of the Email') value='''>
  </td>
</tr>
<tr>
  <td valign='top' align='right'>Your Comments: </td>
  <td align='left'>
	<textarea name='comments' cols='36' rows='10' id='comments' onFocus='if(this.value=='Your comments...') value='''>Your comments...</textarea>
  </td>
</tr>
<tr>
  <td valign='top'>&nbsp;</td>
  <td><input type='submit' value='..:: SEND ::..'></td>
</tr>
  </table>   
</form>
Let me explain this a little bit, in case you are confused.

The user pulls up the page (http://domain.com/index.php?pageid=5) and that shows the contact form. They fill in the values and click send. The script sends the values to itself, and refreshes. So from there, the top script checks to see if the hidden variable 'contact' has been set to 'send'. If so, then it loops through the error handeling and sets the error code to the correct code, and the pageID to the contact form.

The contact form is a 5 part switch of each error code. Each code gives a different form. Right now, I'm not getting too much to happen other than the page refreshes, and my content then disappears. No thank-you page, no error page, nothing.

Any help would be greatly appreciated. I am continuing to work on this after I post this, so if I all of the sudden post [RESOLVED] in front of the title, I got it working.

Feel free to IM me (bpat1434) if you want to.

~Brett

Posted: Sat Feb 19, 2005 11:26 pm
by feyd
it would appear to be an issue with your headers. Analyze emails that make it through, matching up what headers they use to boil it down to a list of ones to try, in individual and in combination.

Posted: Sat Feb 19, 2005 11:33 pm
by brett2
Unfortunately NO emails make it through.

~Brett

Posted: Sat Feb 19, 2005 11:40 pm
by feyd
I'm not talking about emails from this that make it through, I'm talking about other emails that have made it through via other mail clients. You may also want to look at the error logs of your server, in case there was a nonvocalized error..

Posted: Sat Feb 19, 2005 11:46 pm
by smpdawg
I've had good luck with the class at this website and I am using it in a commercial site. http://phpmailer.sourceforge.net/

Is this a Linux/Unix box or a Windows machine? Do you have error reporting turned on so you can see any errors/warnings that might occur?

Posted: Sat Feb 19, 2005 11:48 pm
by brett2
Okay, well I'm gonna let this lay for a few hours, the server's not being nice to me, so the server may have the issues.

I'll post back later.

~Brett