dp20011 2012-07-04 05:36
浏览 43
已采纳

如何通过从我的代码附加PHP HTML的另一个页面获取会话变量的值来使Td样式可见?

i wanna know to make my td tag style visible an getting value from another php page in the form of session varialbe as my code is define under,

on else condition fron php page i am setting session variable and redirecting to another page as,

else {
session_start();
$_SESSION['Validation'] = 'on';
header("Location: index.html");
}

after then on index.html page in between table tag i am using this script as,

<?php
session_start();
$foo = $_GET['Validation'];
echo $foo;
?>
<tr><td colspan=2><font face="verdana,arial" size="-1" color="red"       style="visibility:hidden">Wrong username or Password</font></td></tr>

how to make td tag style vissible true and it remain hidden if session variable do not get any value ????

Hopes to listen from you ...

Thanks in Advance

  • 写回答

2条回答 默认 最新

  • douseda0009 2012-07-04 05:42
    关注

    use a simple if... then... else condition and make use of your $_SESSION variable to switch those conditions. Create a new variable to hold your current style e.g. $tdStyle = "visibility: hidden;" or $tdStyle = "visibility: visible;" for hiding/showing your td, respectively.

    HTML/PHP CODE: [EDIT]

    <?php
      ...
      if ($_SESSION['Validation'] == "on") {
         $tdStyle = "visibility: visible;";
      } else  {
         $tdStyle = "visibility: hidden;";
      }
      ...
    ?>
    ...
    <tr><td style="<?php echo $tdStyle; ?>">Wrong username or Password</td></tr>
    ...
    

    EDIT: Use index.php not index.html when embedding PHP codes in HTML or your php code will be treated as plain text/html

    header("Location: index.php");
    
    NOT
    
    header("Location: index.html");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题