将文本框中输入的数量显示到另一页的表格中

时间:2015-07-29 03:40:06

标签: php

所以我在php中有这个页面。我想要做的是当用户在第一页中输入数量时,点击预览后,它将在第二页显示数量。

我只是PHP的初学者,希望有人能提供帮助。 谢谢。

第一页(这是用户输入数量的页面)

    <?php
    include("webconfig.php");
    session_start();
    $_SESSION['qty'] = $qty;

    if(!isset($_SESSION["UID"]) || $_SESSION["ACTIVE"] == '0')
        header("location:login.php");

    $code = $_REQUEST["code"];
    $desc = $_REQUEST["desc"];
    $price = $_REQUEST["price"];
?>

<!DOCTYPE html>
<html>
<head>
    <link href="docs/css/metro.css" rel="stylesheet">
    <link href="docs/css/metro-icons.css" rel="stylesheet">
    <link href="docs/css/docs.css" rel="stylesheet">

    <script src="docs/js/jquery-2.1.3.min.js"></script>
    <script src="docs/js/metro.js"></script>
    <script src="docs/js/docs.js"></script>
    <script src="docs/js/prettify/run_prettify.js"></script>
    <script src="docs/js/ga.js"></script>

    <script type="text/javascript" src="keyboard.js" charset="UTF-8"></script>
    <link rel="stylesheet" type="text/css" href="keyboard.css">

    <title></title>

</head>
<body>
    <div class="page-content">
        <div class="align-center">
            <div class="container">
            <div class="row cells12">
            <ul class="breadcrumbs2">
                <li><a href="index.php"><span class="icon mif-home"></span> Choose Transaction</a></li>
                <li><a href="receiving.php">Receiving</a></li>
                <li><a href="quantity">Enter Quantity</a></li>
                <!-- <li><a href="#">Preview</a></li> -->
            </ul>
            </div>
                <!-- Default -->
                <div class="panel">
                    <div class="content">
                        <div class="grid">
                            <div class="row cells12">
                                <!-- Default -->
                                <div class="panel">
                                    <div class="heading">
                                        <span class="title">ENTER QUANTITY</span>
                                    </div>
                                    <div class="content">
                                        <div class="grid">
                                            <div class="row cells12">
                                                <div class="cell colspan1">
                                                    &nbsp;
                                                </div>
                                                <div class="cell colspan6">
                                                    <div class="panel info">
                                                        <div class="heading">
                                                            PICTURE
                                                        </div>
                                                        <div class="content" style="height:215px;">
                                                            <?php echo "$img";?>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="cell colspan4">
                                                <form>
                                                    <label>Enter quantity</label>
                                                    <div class="input-control text full-size" placeholder="Type search keyword here" data-role="input">
                                                        <input name="qty" class="keyboardInput" style="width: 225px;" type="text">
                                                    </div>
                                                    <div class="cell colspan12">
                                                    <hr>
                                                    <br />
                                                    <button style="width: 95px; height: 95px;" class="button warning rounded large-button"><span class="icon mif-arrow-left" style="height: 22px;"> Back</span></button>
                                                    <button style="width: 95px; height: 95px;" class="button success rounded large-button"><span class="icon mif-plus" style="height: 22px;"> Add</span></button>
                                                    <input type="button" onClick=\"window.open('preview.php?code=$code&desc=$desc&price=$price&img=$img&qty=$qty','mywindow17','menubar=0,location=1,status=1,scrollbars=1,width=1366,height=768,left=0,top=0,screenX=50,screenY=100')\" style="width: 95px; height: 95px;" class="button primary rounded large-button" value="Preview">
                                                    </div>
                                                </form method="GET">
                                                </div>
                                                <div class="cell colspan1">
                                                    &nbsp;
                                                </div>
                                            </div>
                                            <div class="row cells12">
                                                <div class="cell colspan1">
                                                    &nbsp;
                                                </div>
                                                <div class="cell colspan6">
                                                    <div class="panel info">
                                                        <div class="heading">
                                                            ITEM DESCRIPTION
                                                        </div>
                                                        <div class="content" style="text-align: left;">
                                                            <table class="table">
                                                                <thead>
                                                                    <tr>
                                                                        <th>ITEM CODE</th>
                                                                        <th>ITEM NAME</th>
                                                                        <th>ON HAND</th>
                                                                    </tr>
                                                                </thead>
                                                                <?php
                                                                    echo "
                                                                        <tbody>
                                                                        <tr style=\"cursor:pointer;\" onClick=\"window.open('quantity.php?code=$code&desc=$desc&price=$price&img=$img','mywindow17','menubar=0,location=1,status=1,scrollbars=1,width=1366,height=768,left=0,top=0,screenX=50,screenY=100')\">
                                                                            <td>$code</td>
                                                                            <td>$desc</td>
                                                                            <td>$price</td>                                                                         
                                                                        </tr>
                                                                        </tbody>
                                                                        ";  

                                                                ?>
                                                                <!-- <tbody>
                                                                    <tr>
                                                                        <td width="30%"><span class="text-accent">$icode</span></td>
                                                                        <td><span class="text-accent">000000000IM063</span></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td><span class="text-accent">ITEM NAME:</span></td>
                                                                        <td><span class="text-accent">3M DAY / NIGHT FILM (J5-6504) 100MM x 96</span></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td><span class="text-accent">ON HAND:</span></td>
                                                                        <td><span class="text-accent">280</span></td>
                                                                    </tr>
                                                                </tbody> -->
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="cell colspan4">
                                                    &nbsp;
                                                </div>
                                                <div class="cell colspan1">
                                                    &nbsp;
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div><!-- panel -->
                            </div><!-- row cells12 -->
                        </div><!-- grid -->
                    </div><!-- content -->
                </div><!-- panel -->
            </div>
        </div>
    </div>
</body>
</html>

这是第二页(从第一页输入的数量将显示在表格中)

<?php
    include("webconfig.php");
    session_start();
    $qty = $_GET['qty'];

    if(!isset($_SESSION["UID"]) || $_SESSION["ACTIVE"] == '0')
        header("location:login.php");

    $code = $_REQUEST["code"];
    $desc = $_REQUEST["desc"];
    $price = $_REQUEST["price"];
    $qty = $REQUEST["qty"];
?>
<!DOCTYPE html>
<html>
<head>
    <link href="docs/css/metro.css" rel="stylesheet">
    <link href="docs/css/metro-icons.css" rel="stylesheet">
    <link href="docs/css/docs.css" rel="stylesheet">

    <script src="docs/js/jquery-2.1.3.min.js"></script>
    <script src="docs/js/metro.js"></script>
    <script src="docs/js/docs.js"></script>
    <script src="docs/js/prettify/run_prettify.js"></script>
    <script src="docs/js/ga.js"></script>

    <title></title>

</head>
<body>
    <div class="page-content">
        <div class="align-center">
            <div class="container">
                <div class="row cells12">
                    <ul class="breadcrumbs2">
                        <li><a href="index.php"><span class="icon mif-home"></span> Choose Transaction</a></li>
                        <li><a href="receiving.php">Receiving</a></li>
                        <li><a href="quantity.php">Enter Quantity</a></li>
                        <li><a href="preview.php">Preview</a></li>
                        <!-- <li><a href="#">Preview</a></li>-->
                    </ul>
                </div>
                <div class="grid">
                    <div class="row cells12">
                        <div class="cell colspan8">
                            <div class="panel">
                                <div class="content">
                                    <table class="table">
                                        <tbody>
                                            <tr>
                                                <td class="text-accent" colspan="2"><h3>WAREHOUSE INVENTORY SYSTEM</h3></td>
                                            </tr>
                                            <tr>
                                                <td style="text-align: left;"><span class="text-accent">DATE / TIME:</span></td>
                                                <td style="text-align: left;"><span class="text-accent">07 / 14 / 2015 : 10:21AM</span></td>
                                            </tr>
                                            <tr>
                                                <td style="text-align: left;"><span class="text-accent">DOCUMENT NO.</span></td>
                                                <td style="text-align: left;"><span class="text-accent">0000000010</span></td>
                                            </tr>
                                            <tr>
                                                <td style="text-align: left;"><span class="text-accent">ENCODED BY:</span></td>
                                                <td style="text-align: left;"><span class="text-accent">AAAAA</span></td>
                                            </tr>
                                            <tr>
                                                <td style="text-align: left;"><span class="text-accent">TRANSACTION TYPE:</span></td>
                                                <td style="text-align: left;"><span class="text-accent">RECEIVING</span></td>
                                            </tr>
                                            <tr>
                                                <td style="text-align: left;"><span class="text-accent">REFERENCE NO.</span></td>
                                                <td style="text-align: left;"><span class="text-accent">000000001232</span></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <hr class="thin">
                                    <hr class="thin">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>BARCODE</th>
                                                <th>DESCRIPTION</th>
                                                <th style="text-align: center;">QUANTITY</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        echo "
                                            <tr style=\"cursor:pointer;\" onClick=\"window.open('quantity.php?code=$code&desc=$desc&price=$price&img=$img','mywindow17','menubar=0,location=1,status=1,scrollbars=1,width=1366,height=768,left=0,top=0,screenX=50,screenY=100')\">>
                                                <td style=\"text-align: left;\">$code</td>
                                                <td style=\"text-align: left;\">$desc</td>
                                                <td style=\"text-align: center;\">$price</td>
                                            </tr>
                                        ";
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="cell colspan4">
                            <div class="cell colspan12">
                                <button style="width: 95px; height: 95px;" class="button warning rounded large-button"><span class="icon mif-cross" style="height: 36px;"> Cancel</span></button>
                                <button style="width: 95px; height: 95px;" class="button success rounded large-button"><span class="icon mif-plus" style="height: 51px;"><br /> Add again</span></button>
                                <button style="width: 95px; height: 95px;" class="button primary rounded large-button"><span class="icon mif-checkmark" style="height: 36px;"> Finish</span></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- container -->
        </div><!-- align center -->
    </div><!-- page content -->
</body>
</html>

1 个答案:

答案 0 :(得分:0)

尝试使用此方法使用会话

从一个页面获取值到另一个页面

<强> first.php

<?php
 if(!empty($_POST)){
   session_start();
   //get the value form form submission and set it to session
   $_SESSION['testvalue']=$_POST['test'];
   header('location:second.php'); 
  }
?>
<form action="first.php" method="post">
<input type="text" value="" name="test">
<input type="submit" value="test">
</form>

<强> second.php

<?php
 session_start();
 //get the value from session
 $value=$_SESSION['testvalue'];
 echo $value;
?>