Witam,
Jestem nowy na Forum oraz potrzebuje waszej pomocy bo nie moge sobie poradzic z Captcha.
Problem jest tylko jeden ale dla mnie trudny, wszystko dziala jak nalezy ale jak ktos przepisze niepoprawnie captche to i tak wiadomosc zostaje wyslana...
Nie moge sobie poradzic zeby to razem zgrac z php
mam nadzieje ze ktos bylby tak mily i pomoglby mi albo podpowiedzial jak ta linijke w php dostosowac aby to dzialalo..
czyli najlatwiej mowiac jak moge tutdaj dodac linijke ktora wywali blad ze captcha zostala zle przepisana
$json=array("status"=>1,"msg"=>"<p class='status_ok'>Your message has been sent correctly.<br>Within a few seconds you will receive a copy of the sent E-Mail.<br>Thank you very much for using the service from<br>blabla</p>"); }
}
else{
$json=array("status"=>0,"msg"=>"<p class='status_err'>A script error has occurred.<br>Don`t worry, it's okay :)<br>Please try to send the same message again.</p>"); }
}
else{
$json=array("status"=>0,"msg"=>"<p class='status_err'>Please complete the required<br>fields marked with an asterisk *<br>and try to send the message again.</p>"); }
?>
Ponizej przesylam caly kod
ENkontaktmail.php
<?php
header("content-type: application/json; charset=UTF-8"); $fname=isset($_POST['fname']) ?
$_POST['fname'] : ""; $sname=isset($_POST['sname']) ?
$_POST['sname'] : ""; $email=isset($_POST['email']) ?
$_POST['email'] : ""; $phone=isset($_POST['phone']) ?
$_POST['phone'] : ""; $titel=isset($_POST['titel']) ?
$_POST['titel'] : ""; $CaptchaInput=isset($_POST['CaptchaInput']) ?
$_POST['CaptchaInput'] : ""; $datenschutz=isset($_POST['datenschutz']) ?
$_POST['datenschutz'] : ""; $message=isset($_POST['message']) ?
$_POST['message'] : ""; if($fname && $email && $sname && $titel && $message && $CaptchaInput && $datenschutz){
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: 8bit";
$message_body = '
<!DOCTYPE html>
</html>
';
$message_body1 = '
<!DOCTYPE html>
</html>
';
if(mail("sara@blabla.ch","$titel",$message_body,$headers,"-f sara@blabla.ch")){ if(mail("$email","$titel",$message_body1,$headers,"-f sara@blabla.ch")){ $json=array("status"=>1,"msg"=>"<p class='status_ok'>Your message has been sent correctly.<br>Within a few seconds you will receive a copy of the sent E-Mail.<br>Thank you very much for using the service from<br>blabla</p>"); }
}
else{
$json=array("status"=>0,"msg"=>"<p class='status_err'>A script error has occurred.<br>Don`t worry, it's okay :)<br>Please try to send the same message again.</p>"); }
}
else{
$json=array("status"=>0,"msg"=>"<p class='status_err'>Please complete the required<br>fields marked with an asterisk *<br>and try to send the message again.</p>"); }
?>
contact.html
<div class="site-section bg-light text-black"> <div class="col-md-7 mb-5"> <form method="post" action="../../php/ENkontaktmail.php" id="contact_form" onsubmit="return checkform(this);" class="p-5 bg-white"> <h2 class="text-center display-3">Contact form
</h2> <div class="row form-group"> <div class="row form-group"> <div class="text-center" id="CaptchaDiv"></div> <input type="hidden" id="txtCaptcha"> <div class="text-center"><label for="CaptchaInput">Please enter the five-digit security code*
</label> <input type="text" minlength=5 maxlength=5 name="CaptchaInput" id="CaptchaInput" required="required" placeholder="Security code" class="form-control text-center"></div> <div class="row text-center form-group"> <input type="submit" value="Send" class="btn btn-black py-3 px-5"> <div class="text-center text-primary" id="send_form_status"></div>
generator captcha .js
function ValidCaptcha(){
[b]var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('CaptchaInput').value);[/b]
if (str1 == str2){
return true;
}else{
return false;
}
}
function removeSpaces(string){
}
var a
= Math
.ceil(Math
.random
() * 9)+ ''; var b
= Math
.ceil(Math
.random
() * 9)+ ''; var c
= Math
.ceil(Math
.random
() * 9)+ ''; var d
= Math
.ceil(Math
.random
() * 9)+ ''; var e
= Math
.ceil(Math
.random
() * 9)+ ''; var code = a + b + c + d + e;
document.getElementById("txtCaptcha").value = code;
document.getElementById("CaptchaDiv").innerHTML = code;
tak to wyglada
Ten post edytował Ajjlechu 2.01.2021, 16:28:27