2011-10-25 3 views
0

양식을 다시 표시 할 때 도움이 필요합니다.필드가 채워진 양식 다시 표시

기본적으로 현재 사용자는 내 연락처 양식을 작성하고 양식과 내용은 확인 페이지로 전달되며, 재 입력란이 올바르게 입력되면 감사 페이지로 이동합니다.

recaptcha가 부적절하게 입력되면 이미 채워진 입력란과 함께 문의 양식을 다시 표시하고 싶습니다. 어떻게해야합니까? (아래에서 볼 수 있듯이 현재 잘못된 보안 문자로 google에 전송됩니다.)

여기에 내 인증 코드가 나와 있습니다. 어떤 도움도 좋은 것 :

<?php require('sbsquared.class.php'); ?> 
<?php 
    require_once('recaptchalib.php'); 
    $privatekey = "myprivatekey"; 
    $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 
    header("Location: http://www.google.com"); <--- this is the bit that I want to redisplay the form with fields already filled out. 
    } else { 

    $sb = New SBSquared; 

    $name = $_POST['FullName']; 
    $post_keys = array_keys($_POST); 
    $my_db_string = "<table>"; 
    $ip_address = $_SERVER['REMOTE_ADDR']; 
    foreach($post_keys as $field) 
    { 
     if($_POST[$field] != "" && $field != "submit_y" && $field != "submit_x" && $field != "submit_x") 
     { 

      $my_db_string .= "<tr><td><b>".$field.":</b></td><td>"; 
      if($field == "Email") 
      { 
       $my_db_string .= '<a href = "mailto:'.$_POST['Email'].'">'.$_POST['Email'].'</a>'; 
      } 
      else 
      { 
       $my_db_string .= $_POST[$field]; 
      } 

      $my_db_string .= "</td></tr>"; 

     } 
    } 

    $my_db_string .= "<tr><td><b>IP ADDRESS LOGGED: </b></td><td>".$ip_address."</td></tr>"; 

    $my_db_string .= "</table>"; 

    if(get_magic_quotes_gpc() != 1) 
    { 
     $my_db_string = addslashes($my_db_string); 
     $name = addslashes($name); 
    } 

    $conn = $sb->openConnection(); 
    $dts = time(); 
    $sql = "INSERT INTO `contact_queries` VALUES ('', '$name', '$my_db_string', 'n/a', 0, $dts)"; 
    $result = mysql_query($sql, $conn) or die(mysql_error()); 

$content = '<div id="main_middle">'; 

$content .= '<span class="title">'.$sb->dt('Contact').'</span> 
<p>'.$sb->dt('Thank you for your enquiry. We will contact you shortly.').'</p> 


</div>'; 

// admin auto email. 
     $dts = date("d.m.y h:ia", time()); 
     $admin_content = "New contact query at $dts"; 
     $admin_content .= "\n\n--\n\n \r\n\r\n"; 
     mail("email address", 'NOTIFICATION: new query', $admin_content, 'From: email address'); 
     $FILE=fopen("./log/auto-contact.txt","a"); 
     fwrite($FILE, $admin_content); 
     fclose($FILE); 

echo pageHeader($sb); 
echo pageContent($sb, $content); 
echo pageFooter($sb); 
    } 
?> 

답변

0

당신은 아마 이미 자신이 대답,하지만 당신은 reCAPTCHA를 설정할 수 있습니다 경우 HTML5 유효성 검사로 거의 같은 양식을 제출하기 전에 유효성을 검사 할 수 있습니다. Captcha가 올 때까지 사용자가 제출할 수 없습니다. 이제, 그것이 틀린 경우 captcha를 새로 고칠 지 모르지만 captcha를 새로 고칠 때 페이지를 새로 고치지 않도록 사람들이 iFrame에 넣는 것을 볼 수 있습니다.

세션을 사용하여 데이터를 채울 수 있습니다.

관련 문제