Sorry I do not know anything about .php but I have been following some instructions and did have the mail processor working outside of RSD on the below host and working fine with no issues..
Once again this site is being constructed for my Cert IV in IT and as I had to do something a bit more complicated I thought I may as well make something I will get some knowledge out of!
Site is located here: brettburgess.tk/test_centre/
Now when I use the form on the site I do not get any errors and in fact it goes to the Success page "success.html" however you will not see that page as yet.
It should only be something simple, but I can not see it Any help or advice to a tutorial would be great please
The processor:
<?php
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'processorform1')
{
$mailto = 'myemail@hotmail.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'TESTING';
$message = 'Values submitted from web site form:';
$success_url = './contact/success.html';
$error_url = './contact/fail.html';
$error = '';
$eol = "\n";
$max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}
if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
header('Location: '.$success_url);
exit;
}
?>
The HTML
<div class="coffee-span-12">
<form class="form-container form-container-1" name="contact" method="post" action="processor.php" enctype="multipart/form-data" id="indexForm1" onsubmit="return Validatecontact(this)">
<input type="hidden" name="formid" value="processorform1">
<label class="label news-update-label">Would you like us to send you news when we have a sale on?</label>
<label class="label news-contact">Name</label>
<input value="" name="text-name" type="text" class="input-1">
<label class="label news-contact">Email Address</label>
<input value="" name="email-name" type="email" class="email-1">
<label class="label news-contact">Captcha</label>
<select class="select drop-down-1" name="indexCombobox1" id="indexCombobox1">
<option>I am a Robot !</option>
<option>I am NOT a Robot!</option>
</select>
<button type="submit" class="button-submit-1" id="indexButton1">Send</button>
</form>
</div>
</div>
Validation Script
<script>
function Validatecontact(theForm)
{
var regexp;
if (theForm.indexCombobox1.selectedIndex < 0)
{
alert("So you are a Robot?");
theForm.indexCombobox1.focus();
return false;
}
if (theForm.indexCombobox1.selectedIndex == 0)
{
alert("So you are a Robot?");
theForm.indexCombobox1.focus();
return false;
}
return true;
}
</script>