/    Sign up×
Community /Pin to ProfileBookmark

Captcha code Problem

Hi,

I am busy working on the following page
[URL=”http://www.photographytours.co.za/bookings2.php”]http://www.photographytours.co.za/bookings2.php[/URL]

I have utilized the coding that came with this Captcha script and it has worked for the quick enquiry forms and contact page. But for the bookings page, there is a problem – i just want to add the captcha code at the bottom – which i have added, and for the popup (validation scripts) that come up to check if it is correct or not. So it needs to work differently to the other pages, as i don’t know how to edit the coding I have already done to make this page work.

So, I don’t know how to do this.

[B]The incl script file that checks the form looks like this:[/B]

function checkform() {
msg = “”;

// contact details
if (document.frm.fname.value == “”) msg = msg + “- First Namen”;
if (document.frm.lname.value == “”) msg = msg + “- Last Namen”;
if (!emailcheck(document.frm.email.value)) msg = msg + “- A valid email addressn”;
if (document.frm.country.value == “”) msg = msg + “- Countryn”;
if (document.frm.number.value == “” || isNaN(document.frm.number.value)) msg = msg + “- Number of Travellersn”;

// Arrival & Departure

if (!check2dates(“arrival_date”,”depart_date”)) msg = msg + “- Your Arrival and Departure Datesn”;

if (document.frm.where.value == “”) msg = msg + “- Where did you hear about usn”;

// display the form check
if (msg!=””)
{
alert (“Please complete the following:rnrn”+msg);
return false;
}

}

[B]and the script that is supposed to check that the capcha code works looks like this:[/B]

<?php
if(empty($_SESSION[‘6_letters_code’] ) ||
strcasecmp($_
SESSION[‘6_letters_code’], $_POST[‘6_letters_code’]) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= “n The captcha code does not match!”;
}
?

I somehow need to integrate these 2 together. but the one is php and the other is js?

Any help would be much appreciated!
Leigh

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@TecBratDec 16.2011 — I'd let the JS handle what it can handle with the onsubmit method, then on the next page run the PHP check for the captcha.

Alternatively, check out reCAPTCHA: http://www.google.com/recaptcha
Copy linkTweet thisAlerts:
@leighchicauthorDec 16.2011 — Hi, well I have spent hours working out how to integrate this one that I am using on the other forms of this website and want to keep consistency. I know about ReCaptcha - i will try it out for another website perhaps.

I am not a PHP developer. I dont know how to write my own code ;-)

I just know things i am familiar with. I don't understand how i can let the next page only check for captcha? It needs to all be checked before it goes to the next page.

At the moment, the error is that that comment on this page

http://www.photographytours.co.za/bookings2.php

The error message - [B][I]"The captcha code does not match!"[/I][/B] is already displaying and not actually checking for it.

If you have any ideas i could try please let me know, but i cant write my own code :-)

thanks!

Leigh
Copy linkTweet thisAlerts:
@TecBratDec 16.2011 — ... but i cant write my own code[/QUOTE]

Perhaps you should consider posting in a commercial help wanted forum.
Copy linkTweet thisAlerts:
@gxisolutionsDec 30.2011 — Hi there,

1) You do not need to combine the php and JavaScript – The JavaScript is client side and the PHP is server side. The JavaScript will check the form before it is submitted (email is sent), the PHP is used to send the email.

2) Your form currently uses “bookings-thanks.php” to send the email, you need to add the PHP catcher check to this file. You need to add it above the section that sends the email else it will not work.

This is not very complex, I am not sure why other people on this forum are unable to help you.

Wishing you all the best and a fantastic 2012 ?
×

Success!

Help @leighchic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...