Location: PHPKode > projects > RabbitBB - Online Web Storage Project > mywebdrive/PHP_CON/contactform/BSContact.php
<?PHP

class BSContact
{
	function BSContact()
	{
	}

	function submitform($_request, $_response)
	{
		@reset($_request);

		$_response['formerror'] = array();
		$_response['finished'] = false;
		
		if (isset($_request['parampath']))
		{
			include($_request['parampath']);
			foreach($_request as $key=>$value)
			{
				if (isset($fielddata[$key]))
				{
					$_response['formvalue'][$key] = $value;
					
					$_param = $fielddata[$key];
					$_paramarr = explode(":", $_param);

					if ($_paramarr[0]=="text")
					{
						
					}
					elseif ($_paramarr[0]=="email")
					{
						if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $value))
						
						$_response['formerror'] = $this->setarr($_response['formerror'], $key, "EMAILFORMAT");
					}

					if (($_paramarr[1]<strlen($value)) && ($_paramarr[1]>0))
					{
						
						$_response['formerror'] = $this->setarr($_response['formerror'], $key, "TOOLONG");

					}

					if (isset($_paramarr[2]) && ($_paramarr[2]!=""))
					{
						if ($_paramarr[2]=="T")
						{
							if (strlen($value)==0)
							{
								$_response['formerror'] = $this->setarr($_response['formerror'], $key, "EMPTY");

							}
						}
						elseif ($_paramarr[2] == "F")
						{
						}
					}
				}
			}

			if (count($_response['formerror'])==0)
			{
				// Submit
				$msgbody = "Company: " . $_request['f_company'] . "\r\nName: " .
					$_request['f_name'] . "\r\nEmail: " .
					$_request['f_email'] . "\r\nTel No.: " .
					$_request['f_telno'] . "\r\nFax No.: " .
					$_request['f_faxno'] . "\r\nComment: " .
					$_request['f_comment'];
				$pmail = new PHPMailer();

				$pmail->IsSMTP();
				$pmail->Host = "192.168.1.8";
				$pmail->SMTPAuth = false;

				$pmail->From = "hide@address.com";
				$pmail->FromName = "RabbitBB Enquiry";
				$pmail->AddAddress($_request['contactemail']);
				$pmail->WordWrap = 50;
				$pmail->Subject = "Enquiry from RabbitBB.com";
				$pmail->Body = $msgbody;

				if (!$pmail->Send())
				{
					$_response['error'] = "SENDFAIL";
				}
				else
					$_response['finished'] = true;
			}
			else
			{
				$_response['error'] = "PARAMCHECKERROR";
			}
		}
		else
		{
			$_response['error'] = "NOFORMPARAM";
		}

		return $_response;
	}

	function setarr($_arr, $_key, $_value)
	{
		if (!isset($_arr[$_key]))
		{
			$_arr[$_key] = array();
		}
		$_arr[$_key][] = $_value;
		return $_arr;
	}
}

?>
Return current item: RabbitBB - Online Web Storage Project