'Retrieve post from another page
I have this form that sends information to the database and it works perfectly.
Per-ho my question is how can I recover the email that I sent in the form of a post from another page that is a pdf to send through the email as a confirmation of the reservation.
The page to show the information of the reservation if I pass an email inserted to the database works perfectly, it only fails me when retrieving that email in a POST way.
I leave below the php codes of the form, of the insert to the database and the page where I will show the reservation information.
form code
<html>
<head>
<title>Rem la Ràpita</title>
<link rel="icon" type="image/png" href="../images/favicon.png" sizes="32x32"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="../assets/css/courses_styles.css">
<link rel="stylesheet" href="../assets/css/base.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="estilos_reserves.css">
<link rel="stylesheet" href="plugins/sweetalert2/sweetalert2.min.css">
<link rel="stylesheet" type="text/css" href="fuentes/iconic/css/material-design-iconic-font.min.css">
<style type="text/css">
html {
font-size: 100%;
}
</style>
</head>
<body>
<!--Navegador-->
<?php include('nav.php'); ?>
<div class="container-login">
<div class="wrap-login" style="width: 600px">
<form class="login-form validate-form" action="bd/reservar.php" method="post">
<span class="login-form-title"><?php echo $Prova; ?></span>
<div class="wrap-input100" data-validate = "Nom incorrecte">
<input class="input100" type="text" id="nom" name="nom" placeholder="Nom" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate = "Email incorrecto">
<input class="input100" type="text" id="apellidos" name="apellidos" placeholder="Apellidos" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate = "Email incorrecto">
<input class="input100" type="text" id="email" name="email" placeholder="Email" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate="Telefon incorrecto">
<input class="input100" type="text" id="telefon" name="telefon" placeholder="Telefon" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate="Persones incorrecto">
<input class="input100" type="number" id="persones" name="persones" placeholder="Numero de Persones" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate="Data incorrecto">
<input class="input100" type="date" id="data" name="data" placeholder="Fecha" required="required">
<span class="focus-efecto"></span>
</div>
<div class="wrap-input100" data-validate="Hora incorrecto">
<input class="input100" type="time" id="hora" name="hora" placeholder="Hora" required="required">
<span class="focus-efecto"></span>
</div>
<div class="container-login-form-btn">
<div class="wrap-login-form-btn">
<div class="login-form-bgbtn"></div>
<button type="submit" name="submit" class="login-form-btn">RESERVAR</button>
</div>
</div>
</form>
</div>
</div>
<!--footer-->
<?php include('footer.php'); ?>
<!-- Scripts -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/jquery.scrollex.min.js"></script>
<script src="../assets/js/skel.min.js"></script>
<!--Navegador-->
<script type="text/javascript" src="../assets/js/nav.js"></script>
<script type="text/javascript" src="../assets/js/nav1.js"></script>
<!--Login-->
<script src="jquery/jquery-3.3.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="popper/popper.min.js"></script>
<script src="plugins/sweetalert2/sweetalert2.all.min.js"></script>
<script src="codigo_reservar.js"></script>
</body>
</html>
code to insert to database:
<?php
require('dbconnect_create.php');
if (isset($_REQUEST['nom'])) {
$nom = stripslashes($_REQUEST['nom']);
$nom = mysqli_real_escape_string($con, $nom);
$apellidos = stripslashes($_REQUEST['apellidos']);
$apellidos = mysqli_real_escape_string($con, $apellidos);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($con, $email);
$telefon = stripslashes($_REQUEST['telefon']);
$telefon = mysqli_real_escape_string($con, $telefon);
$persones = stripslashes($_REQUEST['persones']);
$persones = mysqli_real_escape_string($con, $persones);
$data = date('Y-m-d', strtotime($_POST['data']));
$hora = $_POST['hora'];
$query = "INSERT into `reservas` (nom, apellidos, email, telefon, persones, data, hora)
VALUES ('$nom', '$apellidos' , '$email', '$telefon', '$persones', '$data', '$hora')";
//Comprovar que no tingui una reserva feta ja
$select_email = mysqli_query($con, "SELECT * FROM reservas WHERE email = '".$_POST['email']."'");
if(mysqli_num_rows($select_email)) {
echo '<script>alert("Ja tens una reserva realitzada per al dia")</script>';
header( "refresh:0;url=../reserves.php" );
}
else {
//Comprovar el email sigue valid revisant la seva estructura
if (preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $email)){
//Comprovar el telefon sigue valid revisant la seva estructura
if (preg_match("/^6[0-9]{8}$/", $telefon)){
//Recullir les dades per realitzar l'insert
$result = mysqli_query($con, $query);
//Executar l'insert a la Base de Dades
if ($result) {
echo '<script>alert("Reserva realitzada correctament.")</script>';
header( "refresh:0;url=../show.php" );
}
else {
echo '<script>alert("Ups. Error al realitzar la reserva.")</script>';
header( "refresh:0;url=../reserves.php" );
}
}
else {
echo '<script>alert("Telefon invalid.")</script>';
header( "refresh:0;url=../reserves.php" );
}
}
else {
echo '<script>alert("Correu electronic invalid.")</script>';
header( "refresh:0;url=../reserves.php" );
}
}
}
else {}
?>
code to display the reservation information
<body>
<?php
ob_start();
include ('bd/dbconnect_create.php');
/*$email = "[email protected]";*/
$email = $_GET['email'];
$sql ="select * from reservas where email = '$email' ";
$re = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($re)){
$id = $row['id'];
$nom = $row['nom'];
$apellidos = $row['apellidos'];
$email = $row['email'];
$telefon = $row['telefon'];
$persones = $row['persones'];
$hora = $row['hora'];
//Recupero data de la BD
$data = $row['data'];
//Canviar format data a d-m-Y
$data_correcta = date("d-m-Y", strtotime($data));
}
?>
<header>
<h1>Justificant Reserva</h1>
<div class="linea"></div>
<address>
<p>Associació Rem la Ràpita</p>
<p>Bar La Xata</p>
<p>[email protected]</p>
<p>La Ràpita</p>
<p>65 222 44 55</p>
</address>
<span><img alt="" src="../images/icono.png" width="30%"></span>
</header>
<article>
<address>
<p class="titul_origens">Origens 2022</p>
<div class="linea"></div>
<p><br></p>
<p>Nom del Client : <?php echo $nom." ".$apellidos;?><br></p>
</address>
<table class="meta">
<tr>
<th><span>Numero Client</span></th>
<td><span><?php echo $id;?></span></td>
</tr>
<tr>
<th><span>Data Reserva</span></th>
<td><span><?php echo $data_correcta;?></span></td>
</tr>
<tr>
<th><span>Hora Reserva</span></th>
<td><span><?php echo $hora;?></span></td>
</tr>
<tr>
<th><span>Numero de Persones</span></th>
<td><span><?php echo $persones;?></span></td>
</tr>
</table>
<table class="inventory">
<thead>
<tr>
<th><span>Telefon del Client</span></th>
<th><span>Email Client</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><span><?php echo $telefon;?></span></td>
<td><span><?php echo $email;?> </span></td>
</tr>
</tbody>
</table>
</article>
<h1>Informació</h1>
<div class="linea"></div>
<div>
<p>Sols es guardara la reserva despres de 15 minuts.</p>
</div>
</body>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|