在已经从一个页面接收数据之后,使用PHP将数据发送到另一个页面
我试图做的是:在将数据从form.php发送到data_received.php之后,我希望data_received.php将其发送到pdf.php,而用户不必填写其他表单。可能吗 这里有些东西 Form.php的表单示例在已经从一个页面接收数据之后,使用PHP将数据发送到另一个页面,php,html,forms,Php,Html,Forms,我试图做的是:在将数据从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>
<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
解决方案在这里!!!
我已经计划好了,希望对你有用
解决方案在这里
form.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>
登录
$(窗口).on('load',function(){
打开(“pdf.php”,“pdf”,“高度=400,宽度=400”);
})
登录
pdf.php
<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>
登录
PDF
日期:
是的,谢谢你,这很有帮助,它显示了我想要的,但我需要的代码,使它检索。还有什么是Page load()和Call pdf.php()呢请发布您的示例代码,然后只有我能做这项工作,您应该更新您的答案以添加一个代码示例,因为在当前状态下,它没有回答问题