Need help with creating a captcha on...

User 171230 Photo


Registered User
6 posts

Hello Everyone. I have a unique need. I am new to coffee cup and I really love it so far. I am using the same form that collect e mails of visitors for a newsletter on 32 different websites. I added the simple form html to the add html area within vsd. I do not know html or php so I was able to find the simple code and php file that controls the processing of the data. I have the global key for a captcha but I have no idea how to implement it. Even though I want the form to look good I don't care at this point.
here is my website address http://www.bodycontouring.biz

Here is the code that I used for the add html body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Form</title>
</head>

<body>
<form action="contact.php" method="post">
Your name<br>
<input type="text" name="cf_name"><br>
Your e-mail<br>
<input type="text" name="cf_email"><br>
Message<br>
<textarea name="cf_message"></textarea><br>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</body>
</html>


This is the php file that I used to process the information called contact.php

<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];

$mail_to = 'info@ourhealthynation.info';
$subject = 'Message from a site visitor '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for your request. Please look forward to our healthy information updates.');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to info@ourhealthynation.info');
window.location = 'index.html';
</script>
<?php
}
?>

I know the site is horrible but I know no coding at all.

i need a captcha widget and where to add the codes. Also I would just like the vistor to enter information without have to see a new page.

Also any other suggestions would be helpful.

This will be the same content and site on 31 other domains.
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

This should help.
http://www.html-form-guide.com/contact- … ptcha.html
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 271657 Photo


Ambassador
3,816 posts

:o
This will be the same content and site on 31 other domains.

Why do you want to do this?
http://moz.com/learn/seo/duplicate-content

How come the logo/title are at the bottom of the page? Seeing a page with no clear info as to who or what the company is makes me think SPAM. I wouldn't trust the site enough to fill in the newsletter form. :(
(...and 32 identical websites really smells like SPAM)

Also, why is the site so wide? (1800px) Most people viewing it will have to scroll horizontally to see everything.
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com
User 38401 Photo


Senior Advisor
10,951 posts

I also have to say that is the nastiest site I've seen in a while. The colors are good, the images are mostly fine, but there is so much on that page that it's extremely over crowded and basically very distracting. I would move some of that stuff to other pages and make it a normal website instead of trying to cram it all together in one big super close almost suffocating page.

Just my 10 cents.

As for the rest, yes I agree totally with Paintbrush, this site wreaks of spamming and scamming to me too, but that's not my problem here I guess lol. Never make your sites without the full information of what the site is (product name, company name or something that at least tells people what they are looking at).

Again just my (and Paintbrushes too) 10 cents :P
User 171230 Photo


Registered User
6 posts

Thank you Eric. I really appreciate that..by the way I really like your site I am trying to learn how to do things with coffee cup and your site is super awesome.
User 171230 Photo


Registered User
6 posts

Eric I noticed on one of your examples you added code to the header of the html box. I was wondering if that is something I need to do to get a recaptcha widget to display or function. I have a contact.html on the server which is the same code I pasted into the body of the html box to get the form to display. I have a contact.php on the server that apparently processes the email that is sent. It works right now but I need to add this recaptcha.
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

Look at this page. Better examples of what you need to do. Sign up add the script to your page and add the .php file to your site.:cool:
http://code.google.com/p/recaptcha/wiki … pRecaptcha
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 464893 Photo


Ambassador
1,611 posts

My impression is you would do better with a shop approach set as a catalog, advertising each product. Aka The Shopping Cart Creator with the Designer thrown in to get the theme right. A form can be added to an additional VSD page to Eric's suggestion. 32 websites are a lot to maintain. One good one should do the job. Better chance of getting good ranking.
The Guy from OZ


User 171230 Photo


Registered User
6 posts

Hey Eric i tried to add the javascript to the form html in vsd and it caused the website to go blank. I know I have to add this code to display the recaptcha widget

<script type="text/javascript"
src="https://www.google.com/recaptcha/api/challenge?k=YOUR_PUBLIC_KEY"
</script>
<noscript>
<iframe src="https://www.google.com/recaptcha/api/noscript?k=YOUR_PUBLIC_KEY"
height="300" width="500" frameborder="0"></iframe><br>
</noscript>

This is what I have in the body of the html box in vsd to display the form so far
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Form</title>
</head>

<body>
<form action="contact.php" method="post">
Your name<br>
<input type="text" name="cf_name"><br>
Your e-mail<br>
<input type="text" name="cf_email"><br>
Message<br>
<textarea name="cf_message"></textarea><br>
<form method="post" action="verify.php">
<?php
require_once('recaptchalib.php');
$publickey = "your_public_key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</body>
</html>

This is the contact.php file that is currently processing the form without a recaptcha

<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
require_once('recaptchalib.php');
$publickey = "6LefNOMSAAAAADyOW0X-f2Nup1TfIPok2RnGcYef
"; // you got this from the signup page
echo recaptcha_get_html($publickey);
$mail_to = 'info@ourhealthynation.info';
$subject = 'Message from a site visitor '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for your request. Please look forward to our healthy information updates.');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to info@ourhealthynation.info');
window.location = 'index.html';
</script>
<?php
}
?>

This is what I need to add to the contact.php file from the information your provided the link to

<?php
require_once('recaptchalib.php');
$privatekey = "YOUR_PRIVATE_KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>

This is a verify.php file that I added from the google recaptcha information prior. It is in the host folder along with the contact.php


<?php
require_once('recaptchalib.php');
$privatekey = "YOUR_PRIVATE_KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>

And I added the recaptchalib.php which is the library apparently , to the folder with contact.php and verify.php.


Hope you can help me pull it together and hopefully I have presented it properly.

thanks
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

In all the codes where it says "YOUR_PRIVATE_KEY" & "your_public_key" did you enter your actual key?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.