ReCaptcha does not redirect to thankyou.php

reCaptcha works correctly and sends my letters from my contact form, but does not redirect to mine thankyou.php. As I said, I get emails, but the default is a blank screen verify.php. I thought it header(location:' ')should work, but it is not. HELP! I am stuck.

<?php
  require_once('folder/recaptchalib.php');
  $privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  $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


    require_once('folder/email.class.php');


        if($_POST){ 


            if ($_POST['leaveblank'] != '' or $_POST['dontchange'] != 'http://'){
                echo 'Could not deliver your message, please try again!';
                exit;
            }

            $message = '<p><b>Name:</b> '.$_POST['name'].'</p>';
            $message .= '<p><b>Email:</b> '.$_POST['email'].'</p>';
            $message .= '<p><b>Phone:</b> '.$_POST['phone'].'</p>';
            $message .= '<p><b>City:</b> '.$_POST['city'].'</p>';
            $message .= '<p><b>State:</b> '.$_POST['state'].'</p>';
            $message .= '<p><b>Regarding:</b> '.$_POST['regarding'].'</p>';
            $message .= '<p><b>Message:</b> '.$_POST['message'].'</p>';

            if($_POST['regarding'] == ''){          
                $to = 'xxxxx@xxxx.com';
                $subject = '';
            }elseif($_POST['regarding'] == ''){
                $to = 'xxxxx@xxxx.com';
                $subject = '';
            }elseif($_POST['regarding'] == ''){
                $to = 'xxxxx@xxxx.com';
                $subject = '';
            }elseif($_POST['regarding'] == ''){
                $to = 'xxxxx@xxxx.com';
                $subject = '';
            }else{
                $to = 'xxxxx@xxxx.com';
                $subject = 'Events: Inquiry';
            }


            $boundary = uniqid('np');

            $headers = "From: xxxxx@xxxx.com" . "\r\n";
            $headers .= "Reply-To: xxxxx@xxxx.com" . "\r\n";
            $headers .= "Return-Path: xxxxx@xxxx.com" . "\r\n"; 
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "X-Priority: 1\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1;boundary=" . $boundary . "\r\n";
            $headers .= "X-MSmail-Priority: High\n"; 
            //mail($to, $subject, $message, $headers);
            email(array($to), $subject, $message);  
            header('Location:thank-you.php');
        }
  }
  ?>
+3
source share
3 answers

Is your page called thankyou.php or thank-you.php? And try the full url:

header('Location: http://www.example.com/thankyou.php');
0
source

I fixed it by replacing the header ('location: _')

with:

echo "<script type='text/javascript'> location.href = '____'; </script>";
0
source

CONTACT, HIDDEN Inputs FORM.html

<input type="hidden" name="MyComments2" id="MyComments2" value="" />

<script>
function validateForm()
{
var x=document.forms["myForm"]["FirstName"].value;
if (x==null || x=="")
  {
  alert("Please fill out FIRST NAME and let us know your inquiry");
  return false;
  }
var x=document.forms["myForm"]["LastName"].value;
if (x==null || x=="")
  {
  alert("Please fill out LAST NAME and let us know your inquiry");
  return false;
  }
var x=document.forms["myForm"]["Email"].value;
if (x==null || x=="")
  {
  alert("Please fill out EMAIL and let us know your inquiry");
  return false;
  }
var x=document.forms["myForm"]["Comments"].value;
if (x==null || x=="")
  {
  alert("Please fill out COMMENTS and let us know your inquiry");
  return false;
  }

}

</script>

RECAPTCHA   https://inko9nito.wordpress.com/2007/12/12/installing-recaptcha-with-php/#comment-136

. , ,

" - ..."

Fixed without using the PHP version of the redirect.

echo "<script type='text/javascript'> location.href = '[YOUR FULL REDIECT PATH]'; </script>";
0
source

All Articles