php - Adding captcha to a form is not working correct -



php - Adding captcha to a form is not working correct -

i seek add together captcha form check link if like.

this link stackoverflow

but can't create work correctly when type captcha wrong nil happen, , still receive mail.

<?php session_start(); $cap = 'noteq'; if ($_server['request_method'] == 'post') { if ($_post['captcha'] == $_session['cap_code']) { // captcha verification correct. here! $cap = 'eq'; } else { // captcha verification wrong. take other action $cap = ''; } $to = "exmaple@mail.com"; // email address $from = $_post['email']; // sender's email address $first_name = $_post['first_name']; $last_name = $_post['last_name']; $ip = $_post['ip']; $subject = "form submission"; $subject2 = "copy of form submission"; $message = $first_name . " " . $last_name . " wrote following:" . " " . $_post['message']; $message2 = "here re-create of message " . $first_name . "\n\n" . $_post['message']; $headers = "from:" . $from; $headers2 = "from:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends re-create of message sender echo "mail sent. give thanks " . $first_name . ", contact shortly."; // can utilize header('location: thank_you.php'); redirect page. } ?>

and here below captcha , submit button.

<!-- captcha --> <input type="text" name="captcha" id="captcha" maxlength="6" size="6"/> <!-- submit button --> <input type="submit" id="captcha" name="captcha" value="submit">

so doing wrong in here ?

thanks help.

both input fields have same name, contents of text field beingness overwritten value of submit button.

change submit buttons name.

<input type="text" name="captcha" id="captcha" maxlength="6" size="6"/> <!-- submit button --> <input type="submit" id="captchabut" name="captchabut" value="submit">

php forms captcha

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -