doumou1864 2012-07-20 02:12
浏览 8
已采纳

使用$ _SESSION一次在div上使用

I want to use one div at a time using an echo and $_SESSION. When I put this on the web it only shows $form. Can you see if I'm doing anything wrong?

    $signedIn ='<h3 id="throughHeader"> Account options</h3><br/>
        <p id="throughP"> <a href="convenientaccountinfo.php> Account Info </a></p><br/>
        <p id="throughP"><a href="convenientaddaddress.php> Add Address </a></p><br/>
        <p id="throughP"> <a href="convenientaddcreditcard.php> Add C. Card </a></p><br/>
        <p id="throughP"> <a href="convenientsignout.php> Sign Out </a></p>';


        $form='<form id="signInForm" method="POST" action=""><h3 id="formHeader">Sign Into Account</h3><br/>
        <p id="pRegister"><a id="register" href="convenientregisterpage.php"> Register </a></p><br/>
        <label>Email Addr:</label><input type="text" name="userEmail" id="email" size="15"/><br/>
        <label>Password:</label><input type="password" name="password" id="password" size="15"/><br/>
        <input type="submit" value="Sign In" id="formSubmit" name="submit"/> </form>';

    $username = $_SESSION['userEmail'];
    if(!$username){
        $signedInForm="$form";
    }
    else{
        $signedInForm="$signedIn";
    }
}

This is the form POST with validating until it sets the $_SESSION. Thanks for looking at it again.

 $email=$_POST['userEmail'];
$password=$_POST['password'];
if(isset($_POST['submit'])){
    if(empty($email) || empty($password)){
    $msg_to_user3="Fill in both fields";
    }
    else{
    $results=mysql_query("SELECT * FROM register WHERE userEmail='$email'");
   if (mysql_num_rows($results)==0)
       $msg_to_user3 ="No such User";
    else
    {
      while ($login_row = mysql_fetch_assoc($results))
      {
       $password_db = $login_row['password'];
       if ($password!=$password_db){
         $msg_to_user3 ="Password doesn't match";
       }
         if ($password_db!=$password){

        $msg_to_user2="<a id='forgetpassword' href='convenientforgotpassword.php'>Forget Password</a>";
     }
       else
       {
          $active = $login_row['active'];
          $userEmail = $login_row['userEmail'];
          if ($active==0){
             $msg_to_user3= "Activate account at ($userEmail) </p>";
      }
         else
          { 
           $_SESSION['userEmail']=$username;//assign session
      }

      }
      }
    }
       }
}   
<html>
    <body>
    <div id="formSignIn">
        <?php echo $signedInForm ;?>
        </div>
    </body>
    </htmo>
  • 写回答

1条回答 默认 最新

  • dongtuan5367 2012-07-22 02:17
    关注

    Ok, I got the $_SESSION working which switched in between the $form and $signedIn variables. And as far as two only showing with the p s I took the ids off and in the a href the quotes weren't closed so it didn't shut each link. Thanks for all your help!!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题