Skip to main content
Known Participant
October 23, 2023
Answered

recaptcha integration in a html page

  • October 23, 2023
  • 2 replies
  • 1787 views

 

 

 

 

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>brief</title>
<style type="text/css">
@import url("webfonts/Audiowide/stylesheet.css");
body,td,th {
    font-family: Audiowide;
    font-size: 14px;
}
body {
    background-image: url(images/wallpaper-sinterklaas-pakjes-op-het-dak.jpg);
    font-size: 18px;
    color: #F5F5F5;
    text-align: left;
}
	.tekst{
    font-size: 24px;
    color: #FFFFFF;
    float: left;
    text-align: left;
	}
	
#form1 #textarea {
    width: 800px;
    height: 500px;
    align-content: center;
    color: #000000;
    font-family: Audiowide;
    text-align: left;
    font-size: 18px;
}
	.naambox {
		   width: 200px;
    height: 35px;
    align-content: center;
    color: #000000;
    font-family: Audiowide;
    text-align: left;
    font-size: 18px;
	}
	.myButton
        {
            background-color: #ED1A1A;
            border: 1px solid #ED1A1A;
            display: inline-block;
            cursor: pointer;
            color: #f0ebf0;
            font-family: Audiowide;
            font-size: 13px;
            font-weight: bold;
			margin: 5px;
            padding: 7px 35px;
            text-decoration: none;
        }
	@media print {
    #printbtn {
        display :  none;
    }
		
}
</style>
<script src='https://www.google.com/recaptcha/api.js'></script>
	
</head>

<body>
<p>Schrijf een brief aan Sinterklaas.</p>
<p>Print hem af en steek hem in je schoen of email hem rechtstreeks naar de Sint</p>
<p>&nbsp;</p>
<form action="mailto:sinterklaas@kiwanis-zonhoven.be" method="post" name="form1" id="form1">
  <p>Jouw naam:
    <textarea name="textarea2" class="naambox" id="textarea2"></textarea>
  </p>
  <p>Jouw bericht aan Sinterklaas</p>
  <p>
    <textarea name="textarea" maxlength="500" autofocus="autofocus" id="textarea" form="form1"></textarea>
  </p>
  <p>&nbsp;</p>  <p>&nbsp;</p><p> 

 <div class="g-recaptcha" data-sitekey="mykey"></div>
<input type="submit" class="myButton" id="printbtn" value="Emailnaar Sinterklaas">
&nbsp;&nbsp;
    <input name="submit" type="button" class="myButton" id="printbtn" value="Print af en steek hem in je schoen" onclick='window.print()' />
      
</p

></form>
<script src='https://www.google.com/recaptcha/api.js?hl=es'></script>
</body>
</html>

I need to integrate recaptcha into my page.
Is this possible in an HTML page?
The form action is a mailto: 

This topic has been closed for replies.
Correct answer osgood_

thanks, I'm still adjusting it a bit to my needs.

thanks, I'm still adjusting it a bit to my needs.
I want to put the name in the "from": so no email address

if(!$error) {
$to="vivke@telenet.be";
$from="vivke@telenet.be";
$subject = "Sinterklaas, you have mail!!";
$feedback = "Letter from: ". $name . "\n";
$feedback .= "\nContent: ". $message . "\n";
$headers = "MIME Version: 1.0";
$headers .= "Content-type:text/html;charset=UTF-8";
mail ($to,$subject, $feedback, $headers, "-f".$from );;
$success = true;
}


quote

thanks, I'm still adjusting it a bit to my needs.
Can I insert a standard from address in the code?
I tried with $from="myemail"; but that doesn't work.


By @LyaSmidtsx

 

Just add the additional code marked in bold below:

 

$to="me@me.com";

$subject = "You have feedback";

$from = "whoever@whoever.com";

$feedback = "Letter from: ". $name . "\n";

$feedback .= "\nThey write: ". $message . "\n";

$headers = "From: $from";

$headers .= "MIME-Version: 1.0";

$headers .= "Content-type:text/html;charset=UTF-8";

mail ($to, $subject, $feedback, $headers);

$success = true;

 

You dont really need the last 2 $headers, that's only if you intend to format the email as html.

2 replies

Nancy OShea
Community Expert
Community Expert
October 23, 2023

Assumes your application uses securely scripted processing, form validation & sanitization procedures, you can add Google's latest reCaptcha API to your form.  However you'll need to obtain a unique Google ID and key to deploy it on your site.  Depending on how much protection your APP requires, use Google's free version 3 or paid Enterprise.

https://www.google.com/recaptcha/about/

https://support.google.com/a/answer/1217728?hl=en

 

 

 

 

Nancy O'Shea— Product User & Community Expert
Known Participant
October 23, 2023

i think i don't need recaptcha, just a name and a message are sent
and this can only be seen in a private environment, it is not the intention to make this public

Nancy OShea
Community Expert
Community Expert
October 23, 2023

ReCaptcha is the title of your topic. 

I answered the topic question.

 

For form data processing script in PHP, use the PHPMailer example on Github.  PHPMailer is a reliable & secure form sending library that's recommended by most server hosts.

https://github.com/PHPMailer/PHPMailer

 

Good luck with your project.

 

Nancy O'Shea— Product User & Community Expert
Community Expert
October 23, 2023

The short answer is yes, but it's complicated. The form needs to be processed in order to use recaptcha. With mailto, the button simply opens the mail client of the end user so there is no validation. So you would need to build a form that has a validation script, then redirect after the validation to a mailto link. Personally it's more work than what it's worth. I would just implement a script to process your form and send you the results (email or to a database) and get rid of mailto.

Known Participant
October 23, 2023

can the page with the form itself be an html and the form action then a php form script?

Legend
October 23, 2023
quote

can the page with the form itself be an html and the form action then a php form script?


By @LyaSmidtsx

 

Yes, if I remember correctly. It's a long time since I used .html file when using a php workflow. If you're using php as part of your workflow then all of your pages may as well be .php even if there is no php in them. The form script obviously needs to go into a .php page where you would point your forms action attribute to, you cant have the php script in the .html page

 

If you are going to use php to process the form then you have 2 options, use the default php mail function IF your server will allow or you may have to use PHPMailer library or similar as some hosts deem it more secure in the hands of amatuer coders and deactivate the default php mail function.