im creating a form using redbean php. however i had trouble in passing id in form.php to thankyou.php . i need to display total price in thank you page after customer submit form. i dont know what im missing in my code. please help me. thank you.
form.php
<?php
session_start();
require_once 'redbean_orm/rb.php';
$connection = new PDO('mysql:host=localhost;dbname=ocms','root','');
R::setup($connection);
$_SESSION["submit"] = '';
if(isset($_POST['submit']) && $_SERVER['REQUEST_METHOD'] === "POST") {
//create table and field
$customerinfo = R::dispense('customer');
$customerinfo->name = $_POST['name'];
$customerinfo->address = $_POST['address'];
$customerinfo->price = $_POST['price'];
$id = R::store($customerinfo);?>
<html>
<body>
<div class="container">
<div class="row">
<div class="col-md-8">
<form action="" method="POST" id="contact-form">
<div class="form-group">
<label>Full Name</label>
<input type="text" class="form-control" name="name" placeholder="Name" required>
</div>
<div class="form-group">
<label>Address</label>
<textarea type="text" class="form-control" name="address" placeholder="Address"></textarea>
<!--<input type="text" class="form-control" name="address" placeholder="Address" required>-->
</div>
<div class="form-group">
<label>Price</label>
<input class="form-control" name="price" value="RM100.00" readonly="readonly" type="text" id="total">
</div>
<div class="form-group">
<button class="btn btn-info" name="submit">
<a href="thankyou.php?id=<?php echo $id;?>"
style="text-decoration: none;">Submit</a></button>
<!--<?php echo R::load('users',$_POST['id']); ?>-->
</div>
</form>
</body>
</html>
thankyou.php
<?php
session_start();
require_once 'redbean_orm/rb.php';
$connection = new PDO('mysql:host=localhost;dbname=ocms','root','');
R::setup($connection);
if (isset($_SESSION["submit"])) {
$userinfo = R::load('users',$_GET['id']);
}
?>
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Thank You</title>
</head>
<body>
<div class="jumbotron text-xs-center">
<h1 class="display-3">Thank You For Your Request!</h1><br>
<p class="lead"><strong>Your total charge :</strong><br>
<?php
foreach (R::find('users') as $customer) {
echo $customer = $_GET['id'].$customer['price'];
}
?>
<!--<input name="price" value="<?php echo $userinfo->price ?>" readonly="readonly" type="text">-->
</p>
<hr>
</div>
</body>
</html>
i am familiar with sql but when used redbean php it quite confusing.
for anyone who is looking for this solution. i found it myself. i shouldnt save price in database. just store in session and send it thankyou.php. Thank you for looking here. solution: inside post, i add $_SESSION['price'] = $_POST['price'];
Then in thankyou.php. i insert echo $_SESSION['price']
.