0

以下仅验证一个文本框 ( 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>"; 
        ?>
4

2 回答 2

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>"; 
    ?>
于 2013-05-26T14:21:02.647 回答
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!";
    }
} 
    ?>
于 2013-05-26T14:18:31.430 回答