猿问

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

我想做的是:在将数据从 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 的回答


婷婷同学_
浏览 113回答 2
2回答

隔江千里

解决方案在这里!表单.php<html><head>&nbsp; &nbsp; <title>Log-in</title>&nbsp; &nbsp; <link rel="stylesheet" type="text/css" href="style.css"></head><body><div class="header">&nbsp; &nbsp; <h1>Log-in</h1></div><form action="data_received.php" method="post"><div data-for="date">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <label>Date</label>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="text" name="date">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div data-for="time">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <label>Time</label>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="text" name="time">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" name="register_btn" class="Register"></td></body></html>&nbsp;data_received.php<html><head>&nbsp; &nbsp; <title>Log-in</title>&nbsp; &nbsp; <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>&nbsp; &nbsp; <script>&nbsp; &nbsp; $(window).on('load', function() {&nbsp; &nbsp; window.open("pdf.php", "pdf", "height=400,width=400");&nbsp; &nbsp; })&nbsp; &nbsp; </script></head><body><div class="header">&nbsp; &nbsp; <h1>Log-in</h1></div><form >&nbsp; &nbsp;<?phpsession_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>&nbsp;pdf文件<html><head>&nbsp; &nbsp; <title>Log-in</title>&nbsp; &nbsp; <link rel="stylesheet" type="text/css" href="style.css"></head><body><div class="header">&nbsp; &nbsp; <h1>PDF</h1></div><form method="post" >&nbsp; &nbsp; <?php&nbsp; &nbsp; session_start();&nbsp; &nbsp; ?>&nbsp; &nbsp; <table>&nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>Date:</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input type="text"&nbsp; value="<?PHP if(isset($_SESSION['date'])){echo $_SESSION['date'];}?>"></td>&nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>Time:</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input type="text" value="<?PHP if(isset($_SESSION['time'])){echo $_SESSION['time'];}?>"></td>&nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input type="Button" value="Close" onclick="self.close();"> </td>&nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; </table></form></body></html>&nbsp;

尚方宝剑之说

解决方案在这里!针对你的疑惑,我已经计划好了,希望对你有用。
随时随地看视频慕课网APP
我要回答