0

我想隐藏一个表单,直到单击一个名为的按钮storeip并将数据从一个名为的输入传递ipstore到一个名为$ipstore.

users_log.php

    $ipstore = $_POST['ipstore'];

    $sql = "SELECT * FROM users_log WHERE u_id = 52 ORDER BY date_log";

    $sql_query = mysql_query($sql);

    $pager = new UL_Pagination($conn, $sql, 5, 5, "param1=valu1&param2=value2");

    /*
     * Enable debugging if you want o view query errors
    */
    $pager->setDebug(true);

    $rs = $pager->paginate();
    if(!$rs) die(mysql_error());

    if(mysql_num_rows($sql_query) > 0)
    {   

    $sorting = array();
    while($row = mysql_fetch_assoc($rs))
    {
        $sorting[$row['logged_date']][] = "<h4 class='bdr-rit' id='c-code'>".$row['c_code']."</h4>"."<h4 class='bdr-rit'><button type='submit' name='storeip'><input type='hidden' name='ipstore' value='".$row['logged_ip']."'/>".$row['logged_ip']."</button></h4>"."<h4 class='bdr-rit'>".$row['login_time']."</h4>"."<h4>".$row['logout_time']."</h4>";
    }

    echo "<form action='' method='post' enctype='multipart/form-data'>";
    echo "<ul>";    
    echo "  <li class='ul-hd'>
            <h4 class='ul-one'>code</h4>
            <h4 class='ul-two'>ip</h4>
            <h4 class='ul-thr'>login</h4>
            <h4 class='ul-for'>logout</h4>
            </li>   ";  

    foreach($sorting as $key => $value)
    {
        echo "<li>".$key."<li>";        
        foreach ($value as $data)
        {
            echo "<li>".$data."</li>";
        }
    }

    echo "</ul>";
    echo "<form>";

users_log用 ip 和国家代码来显示用户登录和登录信息,一个名为的按钮storeip会将ip地址传递到下一个hidden form,单击它。

主页.php

    // include pagination class
    include('include/ul_pagination.php');

    // db connection
    include('c-db.php');

    if ( isset( $_POST["storeip"] ) and !empty($ipstore) )
    {       
    echo "<form action='' method='post' enctype='multipart/form-data'>";
    echo "<ul>";    
    echo "  <li class='ul-hd'>
            <h4 class='ul-one'>ip</h4>
            <h4 class='ul-fiv'>".$ipstore."</h4>
            </li>
            <li class='ul-hd'>
            <h4 class='ul-one'>code</h4>
            <h4 class='ul-two'>country</h4>
            <h4 class='ul-thr'>city</h4>
            <h4 class='ul-for'>flag</h4>
            </li>   ";
    echo "</ul>";
    echo "<form>";      
    }
    else
    {
     include('include/users_log.php');
    }

    mysql_close($conn);

上面的代码是显示users_log页面,直到用户不需要看到隐藏的表单。隐藏表单包含详细信息ip,这就是为什么我需要ip从隐藏表单派生地址users_log以显示有关ip. 当我添加print_r($_POST)users_log页面顶部时,之后,当我单击ip地址按钮时,它会显示Array ( [storeip] => [ipstore] => 127.0.0.1 ),但仍然无法弄清楚我在哪里做错了。帮助我或提出你的好主意,每一个建议都将不胜感激,并感谢所有人。

4

0 回答 0