在PHP中为表分配表

时间:2013-05-26 14:11:10

标签: php

以下仅验证一个文本框(txt1)。如果我有一系列位于表格中的文本框(动态填充),如何将文本框的整个值分配给一个会话?

有可能吗?

或者你能建议我出路吗?

       <?php
        if(isset($_POST['sendtwo']))
           {   if($_POST['txt1'] == '')
            {echo 'txt1 is empty!'; return;} else {$_SESSION['loged'] = $_POST['txt1'];}
           }
        if(isset($_POST['sendt']) || isset($_POST['sendtwo']))
        {if(isset($_SESSION['loged'])) echo $_SESSION['loged']; echo "<table border='1'><tr><td>form 2 is here!</rd></tr>"; 
        ?>

2 个答案:

答案 0 :(得分:0)

   //try this
   <?php
    if(isset($_POST['sendtwo']))
       {   if($_POST['txt1'] == '')
        {echo 'txt1 is empty!';} else {$_SESSION['loged'] = $_POST['txt1'];}
       }
    if(isset($_POST['sendt']) || isset($_POST['sendtwo']))
    {
    if(isset($_SESSION['loged'])) {
    echo $_SESSION['loged']; 
    echo " border='1'>form 2 is here!";
    }
} 
    ?>

答案 1 :(得分:0)

这样的东西?我不确定你的意思:

   <?php
    if(isset($_POST['sendtwo']))
       {
       if($_POST['txt1'] == '')
        {echo 'txt1 is empty!'; return;}
       else{
          foreach($_POST as $Key => $Posted)
            $_SESSION[$Key] = $Posted;
          }
       }
    if(isset($_POST['sendt']) || isset($_POST['sendtwo']))
    {if(isset($_SESSION['loged'])) echo $_SESSION['loged']; echo "<table border='1'><tr><td>form 2 is here!</rd></tr>"; 
    ?>