php会话奇怪的行为,

时间:2013-06-07 15:32:20

标签: php session

我的项目有近10-15个会话变量,但这些行为很奇怪。我打算做的事情不会发生。

<?php
session_start();

include("users/include/config.php");


if(isset($_SESSION['sessioncheck'])) {
    if($_SESSION['sessioncheck']=="yes") {
        $_SESSION['sessioncheck']="no";
    }
    else {
        header('Location: search2.php');
    }
}
else {
    header('Location: search2.php');
}

if(isset($_POST['url'])) {
    $_SESSION['url']=$_POST['url'];
}
else {
    header('Location: search2.php');
}

//initialising session vars    
$_SESSION['error']=0;
$_SESSION['verify']="no";

?>

 <script type="text/javascript">
     var RecaptchaOptions = {
         theme : 'clean'
     };
 </script>

<script type="text/javascript">
    function robouser() {
        var req = document.form3.recaptcha_challenge_field.value;
        if(req=="") {
            alert ("chalange field required");
            document.form3.recaptcha_challenge_field.focus();
            return false;
        }

        var res = document.form3.recaptcha_response_field.value;
        if(res=="") {
            alert ("enter the fields");
            document.form3.recaptcha_response_field.focus();
            return false;
        }       
    }
</script>

<?php
    $_SESSION['searcheduser']=$_POST['user'];   //session var setting
    $_SESSION['searchedquery']=$_POST['searched'];

    $eq=$_POST['searched'];
    $eu=$_POST['user'];

    //empty query
    if($_SESSION['error']==0) {
        if($eq=="") {
        $_SESSION['error']=1;
        }
    }


    //empty user name
    if($_SESSION['error']==0) {
        if($eu=="") {
            $_SESSION['error']=2;
        }
    }

    //captcha
    echo $_SESSION['error'];
    if($_SESSION['error']==0) {
        $_SESSION['verify']=1;
    ?>

     <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers -->

    <table style="height:100%;width:100%;" >
    <tr>
    <td style="height:100%;width:20%">
    <?php
    /*
    header page
    */
    include "left.php";

?>
</td>


<td>
<?php
/*
header page
*/
    include "header.html";
?>



<!-- your HTML content -->
<div style="text-align:center;">
      <form method="post" name="form3" action="verify.php" onSubmit="return robouser()";>
        <?php
          require_once('recaptchalib.php');
          $publickey = "6LcNQ-ISAAAAAOKfaUtroUoOqdd-4pCUN9Swbwer"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>
        <input type="submit" />
      </form>
</div>
      <!-- more of your HTML content -->
</td>


<td style="height:100%;width:20%">

<php
include "right.php";
?>

</td>

</table>
    </body>
<?php
}
else
{
    $_SESSION['verify']=0;
    $_SESSION['responce']=1;
    header('Location: responce.php');
    // redirect to unsetting session page and redirecting one 
}
?>

在这种情况下使用$ _SESSION [&#39;错误&#39;]在大多数情况下它的值是相同的。它会在空搜索完成时激活。但是,在10个案例中,有7个案例没有问题,其他案例的表现很奇怪。虽然搜索包含关键字 - 为什么?

0 个答案:

没有答案