PDA

View Full Version : A Question About Captcha Code



volkantr19
03-12-2016, 06:17 PM
Hello everybody;

I have a problem with captcha code...
If i add this template to directory,the captcha code isn't shown...
But on the original template going everything fine...

This is the orginal template: http://html.creaws.com/kiddy/contact-us.html
This is the same template which i want to use: http://bbb.antalyabalikcilik.com.tr/contact-us.html

Please help me,what is wrong ?

Thank you for your help in advance...

mlegg
03-12-2016, 07:30 PM
the only difference in your code is in the working page you have this
<!-- Mirrored from html.creaws.com/kiddy/contact-us.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 09 Mar 2016 12:02:26 GMT -->

https://www.diffnow.com/ is a good page to input to see differences

volkantr19
03-12-2016, 07:49 PM
Thanks for answer...
What should i do for working captcha code on my contact page ?
Which code i must add or delete ?

mlegg
03-13-2016, 12:44 AM
Do you have the http://html.creaws.com/kiddy/php/contacts-process.php uploaded to your server?

mlegg
03-13-2016, 01:04 AM
I just noticed you have an extra </li> end tag

</li><div class="header_logo_part with_border" role="banner">

there are no alt tags in the img html either

validate your html code for errors at
https://validator.w3.org/

https://html5.validator.nu/

volkantr19
03-13-2016, 02:43 PM
Do you have the http://html.creaws.com/kiddy/php/contacts-process.php uploaded to your server?


No,i didn't upload this php file to the server?

This php file isn't related with captcha code...
The problem is: captcha code isn't shown on the page...

volkantr19
03-14-2016, 08:36 AM
I tried everthing but still same problem...

When the webpage loads no captcha image shows up, just an image placeholder...

Still thinking about this problem...

jscheuer1
03-14-2016, 08:34 PM
These are two different servers right? Anyways, the captcha image (missing on the bad page - 404 not found, and obviously there on the working page) is generated by PHP. So we really cannot see the problem by looking at the HTML/css/javascript involved. Now, you could try linking to the capcha image on the good server, if that's allowed and isn't blocked, and if it would work as a capcha (might not, because for a captcha to work, the page it's on has to 'know' the right answer). Otherwise you would have to make sure the server where you are having the problem has both PHP support and the files and libraries required to generate and use the capcha image.

The 'bad' page is also missing a number of other resources available on the good page. However, since this most likely is a server side issue, fixing those might not help. Here they are though (can't hurt to fix them):



http://bbb.antalyabalikcilik.com.tr/js/jquery.js Failed to load resource: the server responded with a status of 404 (Not Found)send @ jquery.js:5
http://bbb.antalyabalikcilik.com.tr/tuner/tuner/images/switcher_img/menu-01.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://bbb.antalyabalikcilik.com.tr/tuner/tuner/images/switcher_img/menu-02.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://bbb.antalyabalikcilik.com.tr/tuner/tuner/images/switcher_img/menu-03.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://bbb.antalyabalikcilik.com.tr/tuner/tuner/images/switcher_img/theme-style-02.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://bbb.antalyabalikcilik.com.tr/tuner/tuner/images/switcher_img/theme-style-01.png Failed to load resource: the server responded with a status of 404 (Not Found)

volkantr19
03-14-2016, 11:03 PM
Thank you for your answer Mr. John...
I created new php file for the captcha code....Finally its working (shows up)...But i still don't know how !!!
New problem is contact form don't send any message to my email....I know,there is some wrong code...

You can try too,form dont send message...
http://bbb.antalyabalikcilik.com.tr/contact-us.html

Please check this codes...Is there any mistake ????


html code:



<!-- contact form -->
<div class='grid_col grid_col_8'>
<div class='ce clearfix'>
<h3 class="ce_title">Drop us a line</h3>
<div>
<div role="form" class="cf" id="cf-f16-p10-o1" lang="en-US" dir="ltr">
<div class="screen-reader-response"></div>
<form action="php/contacts-process.php" method="post" class="cf-form contact-form" novalidate="novalidate">
<p>Name*
<br />
<span class="cf-form-control-wrap your-name"><input type="text" name="name" value="" size="107" class="cf-form-control cf-text cf-validates-as-required" aria-required="true" aria-invalid="false" /></span> </p>
<p>Email*
<br />
<span class="cf-form-control-wrap your-email"><input type="email" name="email" value="" size="107" class="cf-form-control cf-text cf-email cf-validates-as-required cf-validates-as-email" aria-required="true" aria-invalid="false" /></span> </p>
<p>Message
<br />
<span class="cf-form-control-wrap your-message"><textarea name="message" cols="107" rows="8" class="cf-form-control cf-textarea" aria-invalid="false"></textarea></span> </p>
<p>
<span class="captcha-wrapper">
<iframe src="php/capcha.php" class="capcha-frame" name="capcha_image_frame"></iframe>
<input class="verify" type="text" id="verify" name="verify" />
</span>
<input type="submit" value="Send" class="cf-form-control cf-submit" />
</p>
<div class="cws_msg_box error-box clearfix">
<div class="icon_section"><i class="fa fa-exclamation"></i></div>
<div class="content_section">
<div class="msg_box_title">Error box</div>
<div class="msg_box_text"></div>
</div>
</div>
</form>
<div class="email_server_responce"></div>
</div>
</div>
</div>
</div>
<!-- / conatct form -->




js code:




/* contact form */
if (jQuery(".contact-form").length) {
/**/
/* contact form */
/**/

/* validate the contact form fields */
jQuery(".contact-form").each(function(){

jQuery(this).validate( /*feedback-form*/{
onkeyup: false,
onfocusout: false,
errorElement: 'p',
errorLabelContainer: jQuery(this).find('.msg_box_text'),
rules:
{
name:
{
required: true
},
email:
{
required: true,
email: true
},
message:
{
required: true
},
verify: {
required: true,
remote: {
url: 'php/capcha.php',
type: "post",
data:
{
code: function()
{
return jQuery('.verify').val();
}
}
}
}
},
messages:
{
name:
{
required: 'Please enter your name',
},
email:
{
required: 'Please enter your email address',
email: 'Please enter a VALID email address'
},
message:
{
required: 'Please enter your message'
},
verify: {
required: 'Please enter Captcha',
remote: "Please enter a VALID Captcha"
}
},
invalidHandler: function()
{
jQuery(this).find(".cws_msg_box.error-box").slideDown('fast');
jQuery("#feedback-form-success").slideUp('fast');

},
submitHandler: function(form)
{
jQuery(form).find(".cws_msg_box.error-box").slideUp('fast');
var $form = jQuery(form).ajaxSubmit();
submit_handler($form, jQuery(form).parent().children(".email_server_responce") );
}
});
})

/* Ajax, Server response */
var submit_handler = function (form, wrapper){

var $wrapper = jQuery(wrapper); //this class should be set in HTML code

$wrapper.css("display","block");
var data = {
action: "email_server_responce",
values: jQuery(form).serialize()
};
//send data to server
jQuery.post("php/contacts-process.php", data, function(s_response) {
s_response = jQuery.parseJSON(s_response);
if(s_response.info == 'success'){
$wrapper.addClass("message message-success").append('<div class="cws_msg_box success-box clearfix"><div class="icon_section"><i class="fa fa-thumbs-up"></i></div><div class="content_section"><div class="msg_box_title">Success!</div><div class="msg_box_text">Your message was successfully delivered.</div></div></div>');
$wrapper.delay(5000).hide(500, function(){
jQuery(this).removeClass("message message-success").text("").fadeIn(500);
$wrapper.css("display","none");
});
jQuery(form)[0].reset();
} else {
$wrapper.addClass("cws_msg_box error-box clearfix").append("<div class='icon_section'><i class='fa fa-exclamation'></i></div><div class='content_section'><div class='msg_box_title'>Server fail!</div><div class='msg_box_text'><p> Please try again later!</p></div></div>");
$wrapper.delay(5000).hide(500, function(){
jQuery(this).removeClass("cws_msg_box error-box clearfix").text("").fadeIn(500);
$wrapper.css("display","none");
});
}
});
return false;
}
}

/**/



php code:



<?php
if(!session_id()) {
session_start();
}
error_reporting(0);

if (isset($_REQUEST['action'])) {
if ($_REQUEST['action'] == "php/contacts-process.php") {
$ourMail = "volkan19@hotmail.com";
$pre_messagebody_info = "";
$errors = array();
$data = array();
parse_str($_REQUEST['values'], $data);

$result = array(
"is_errors" => 0,
"info" => ""
);
if (!empty($errors)) {
$result['is_errors'] = 1;
$result['info'] = $errors;
echo json_encode($result);
exit;
}
}
}
}
?>

jscheuer1
03-15-2016, 01:00 AM
Since you have the image working, that tells us the server has PHP at least. So, either there is an error or overzealous validation with either the javascript or the PHP. One thing that looks fishy to me right off in the PHP is this line:


if (isset($_REQUEST['action']))

In this case 'action' is a property of the form tag, neither that property nor its value is sent when the form is submitted. At least not as part of the $_REQUEST object. So that would always be false. That's probably it. A property/value pair of a form element from within the form should be used. The console did not detect any javascript error, so - unless the javascript is being overzealous, I would think fixing the PHP should take care of it. I can guarantee that action will never be set though, not with this setup, so as I say, you would need to go after something else on the PHP side for it to ever get past that first test there.