Page 1 of 1

the submit button does not work

Posted: Wed Feb 05, 2020 4:05 pm
by Machiel
my form does not work, I made an update and make a new project but the contactform does not work, the submit button works anfd I recieve the okay page but I collect no mail in my box.
The page setting php.
Befor I make it with W14 it works on my websites.
Can someone help me.

http://www.zanggroepstellanova.nl/page1.php

<?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' && isset($_POST['formid']) && $_POST['formid'] == 'form1')
{
$mailto = 'mhermes@become-mine.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Website form';
$message = 'Values submitted from web site form:';
$success_url = './okay.html';
$error_url = './error.html';
$eol = "\n";
$error = '';
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$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;

try
{
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address (" . $mailfrom . ") is invalid!\n<br>";
throw new Exception($error);
}
$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)
{
$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);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<title>page</title>
<link href="Zanggroepstellanova.css" rel="stylesheet" type="text/css">
<link href="page1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wb_Form1" style="position:absolute;left:470px;top:162px;width:315px;height:126px;z-index:5;">
<form name="contact" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1">
<input type="hidden" name="formid" value="form1">
<label for="Editbox1" id="Label1" style="position:absolute;left:10px;top:15px;width:35px;height:16px;line-height:16px;z-index:0;">Name:</label>
<input type="text" id="Editbox1" style="position:absolute;left:63px;top:15px;width:190px;height:16px;z-index:1;" name="name" value="" spellcheck="false">
<label for="Editbox2" id="Label2" style="position:absolute;left:10px;top:46px;width:35px;height:16px;line-height:16px;z-index:2;">Email:</label>
<input type="email" id="Editbox2" style="position:absolute;left:63px;top:45px;width:190px;height:16px;z-index:3;" name="email" value="" spellcheck="false">
<input type="submit" id="Button1" name="" value="Send" style="position:absolute;left:63px;top:77px;width:96px;height:25px;z-index:4;">
</form>
</div>
</body>
</html>

Re: the submit button does not work

Posted: Wed Feb 05, 2020 4:37 pm
by Pablo
Did you read the related FAQ: "Emails are not arriving in my inbox" ?
viewtopic.php?f=10&t=32967

Re: the submit button does not work

Posted: Wed Feb 19, 2020 4:43 pm
by Machiel
I did read all the Faq for forms but nothing works.
I send my form and recieve the okay page.
But see nothing in my mailbox, I try to sending it to a gmail account but nothing.
I contact my hosting platform but they tell me to make a new script php for money, i did refuse that, because last year i make a few forms and they did work.
On this time I don't no what to do.

Re: the submit button does not work

Posted: Wed Feb 19, 2020 5:03 pm
by Pablo
You do not have to worry that there is something wrong with script, because if there were any known issues then they would have already been fixed.
This can only be a configuration related issue. However, to be able to help you, I fisrs need to know why the server (your web host) does not send the email. Are there any errors in the server log?

Re: the submit button does not work

Posted: Wed Feb 19, 2020 5:19 pm
by NDV
Perhaps the host operator is blocking port 465. Used “sendmail” as an option, there is no guarantee, but you need to try.

Google settings SMTP
Image
Image

Re: the submit button does not work

Posted: Wed Feb 19, 2020 8:21 pm
by Machiel
This the html page but I think someting go wrong after sending because i send it to my gmail but nothing there.


<?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' && isset($_POST['formid']) && $_POST['formid'] == 'layoutgrid6')
{
$mailto = 'giel.hermes@gmail.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$mailcc = 'mhermes@become-mine.com';
$subject = 'Website form';
$message = 'Values submitted from web site form:';
$success_url = './okay.html';
$error_url = './error.html';
$eol = "\n";
$error = '';
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'Cc: '.$mailcc.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;

try
{
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address (" . $mailfrom . ") is invalid!\n<br>";
throw new Exception($error);
}
$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)
{
$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);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
<!doctype html>
<html>
<head>
<title>page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="Zanggroepstellanova.css" rel="stylesheet">
<link href="page1.css" rel="stylesheet">
<script src="jquery-1.12.4.min.js"></script>
<script src="skrollr.min.js"></script>
<script>
$(document).ready(function()
{
function skrollrInit()
{
skrollr.init({forceHeight: false, mobileCheck: function() { return false; }, smoothScrolling: false});
}
skrollrInit();
});
</script>
<!-- Insert Google Analytics code here -->
</head>
<body>
<div id="container">
</div>
<div id="wb_LayoutGrid6">
<form name="Contact" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="LayoutGrid6">
<input type="hidden" name="formid" value="layoutgrid6">
<div class="row">
<div class="col-1">
<input type="text" id="Editbox4" style="display:block;width: 100%;height:42px;z-index:0;" name="name" value="" spellcheck="false" placeholder="Name" data--100-bottom="transform:translate(0%,0px);" data-bottom-top="transform:translate(200%,0px);">
<input type="text" id="Editbox3" style="display:block;width: 100%;height:42px;z-index:1;" name="email" value="" spellcheck="false" placeholder="Email address" data--100-bottom="transform:translate(0%,0px);" data-bottom-top="transform:translate(200%,0px);">
<input type="text" id="Editbox5" style="display:block;width: 100%;height:42px;z-index:2;" name="subject" value="" spellcheck="false" placeholder="Subject" data--100-bottom="transform:translate(0%,0px);" data-bottom-top="transform:translate(200%,0px);">
</div>
<div class="col-2">
<textarea name="TextArea1" id="TextArea1" style="display:block;width: 100%;;height:99px;z-index:3;" rows="3" cols="56" spellcheck="false" placeholder="MESSAGE" data--100-bottom="transform:translate(0%,0px);" data-bottom-top="transform:translate(200%,0px);"></textarea>
<input type="submit" id="Button2" name="" value="SEND MESSAGE" style="display:block;width: 100%;;height:42px;z-index:4;" data--100-bottom="transform:translate(0%,0px);" data-bottom-top="transform:translate(400%,0px);">
</div>
</div>
</form>
</div>
</body>
</html>

Re: the submit button does not work

Posted: Wed Feb 19, 2020 9:15 pm
by Pablo
The code is correct, so if your host support PHP mail then the email should be sent.
Note that some hosts may require SMTP authentication, which can be configured in the Advanced properties of the form.