为了账号安全,请及时绑定邮箱和手机立即绑定

在已经从页面接收数据后使用 PHP 将数据发送到另一个页面

在已经从页面接收数据后使用 PHP 将数据发送到另一个页面

PHP
婷婷同学_ 2023-04-02 15:06:45
我想做的是:在将数据从 form.php 发送到 data_received.php 之后,我希望 data_received.php 将其发送到 pdf.php,而无需用户填写另一个表格。那可能吗?这是东西form.php 的表单示例<form action="data_received.php" method="post"><div data-for="date">                        <label>Date</label>                        <input type="text" name="date">                    </div><div data-for="time">                        <label>Time</label>                        <input type="text" name="time">                    </div>data_received.php:<?php$date = $_POST['date'];$time = $_POST['time'];echo '$date';echo '$time';?><button onclick="window.location.href = 'pdf.php';">Print to pdf </button><button onclick="windoe.location.href = 'form.php';>Back</button>我只想知道如何让用户对 pdf.php 的 $date 和 $time 的回答
查看完整描述

2 回答

?
隔江千里

TA贡献1906条经验 获得超10个赞

解决方案在这里!


表单.php


<html>

<head>

    <title>Log-in</title>

    <link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div class="header">

    <h1>Log-in</h1>

</div>


<form action="data_received.php" method="post">


<div data-for="date">

                        <label>Date</label>

                        <input type="text" name="date">

                    </div>

<div data-for="time">

                        <label>Time</label>

                        <input type="text" name="time">

                    </div>

                    <input type="submit" name="register_btn" class="Register"></td>

</body>

</html> 

data_received.php


<html>

<head>

    <title>Log-in</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <script>

    $(window).on('load', function() {

    window.open("pdf.php", "pdf", "height=400,width=400");

    })

    </script>

</head>

<body>

<div class="header">

    <h1>Log-in</h1>

</div>


<form >

   <?php

session_start();

$date = $_POST['date'];

$time = $_POST['time'];

$_SESSION["date"] = $_POST['date'];

$_SESSION["time"] = $_POST['time'];

echo $date;

echo '<br/>';

echo $time;

?>

<br/>

<input type="Button" value="Back" onclick="windoe.location.href ='form.php';">

<input type="Button" value="Print to pdf " onclick="window.location.href = 'pdf.php';">


</form>

</body>

</html> 

pdf文件


<html>

<head>

    <title>Log-in</title>

    <link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div class="header">

    <h1>PDF</h1>

</div>

<form method="post" >

    <?php

    session_start();

    ?>

    <table>

        <tr>

            <td>Date:</td>

            <td><input type="text"  value="<?PHP if(isset($_SESSION['date'])){echo $_SESSION['date'];}?>"></td>

        </tr>

        <tr>

            <td>Time:</td>

            <td><input type="text" value="<?PHP if(isset($_SESSION['time'])){echo $_SESSION['time'];}?>"></td>

        </tr>

        <tr>

            <td></td>

            <td><input type="Button" value="Close" onclick="self.close();"> </td>

        </tr>

    </table>

</form>

</body>

</html> 


查看完整回答
反对 回复 2023-04-02
?
尚方宝剑之说

TA贡献1788条经验 获得超4个赞

解决方案在这里!针对你的疑惑,我已经计划好了,希望对你有用。

//img1.sycdn.imooc.com//642929e40001f67b04920471.jpg


查看完整回答
反对 回复 2023-04-02
  • 2 回答
  • 0 关注
  • 73 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信