Member Avatar for Member #5881

I am not sure which forum to post this in, if this is the wrong one, please forgive me and tell me where to post.

I would like the info that is put in on the contact me page to show up on the confirmation page so that the person can see what info they sent.
I want my confirmation page to show

You message has been sent
We will email you at (the info they put in should show up here)
or call you at (the info they put in should show up here)

Thanks for you help/advice

Dani AI

Generated

A simple, robust pattern that avoids duplicate submissions and keeps user data safe is: validate the incoming POST, save the cleaned values in the server session, redirect to a confirmation page (PRG pattern), show the sanitized values there, and offer an Edit or Confirm action. As suggested, show the submitted info — but prefer a session + redirect flow rather than relying only on re-posting hidden fields. , if values are coming up empty, also check that each input has a correct name attribute and that your form action/method are set correctly.

Implementation sketch (server-side workflow)

  1. process the initial POST: trim and validate fields, store the cleaned array in $_SESSION['form_values'].
  2. redirect to confirm.php. On that page read $_SESSION['form_values'], display each value escaped with htmlspecialchars().
  3. Provide two buttons: Edit (returns to the form and pre-fills fields from session) and Send (final handler). Re-validate server-side in the final handler, perform the send, then clear the session entry to avoid repeats.

Example (session + PRG, minimal):

// process.php
session_start();
$vals = [
  'name' => trim($_POST['name'] ?? ''),
  'email' => trim($_POST['email'] ?? ''),
  'phone' => trim($_POST['phone'] ?? ''),
  'message' => trim($_POST['message'] ?? '')
];
$errors = [];
if ($vals['name'] === '') $errors[] = 'Name required';
if (!filter_var($vals['email'], FILTER_VALIDATE_EMAIL)) $errors[] = 'Invalid email';
if ($errors) { $_SESSION['form_errors']=$errors; $_SESSION['form_values']=$vals; header('Location: contact.php'); exit; }
$_SESSION['form_values'] = $vals;
header('Location: confirm.php'); exit;
// confirm.php (read-only preview)
session_start();
$vals = $_SESSION['form_values'] ?? [];
if (!$vals) { header('Location: contact.php'); exit; }
function e($s){ return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); }
echo "We will email you at " . e($vals['email']) . " or call you at " . e($vals['phone']);

Final tips

  • Always escape displayed values (htmlspecialchars) to prevent XSS.
  • Re-validate before the final send and clear session data after success.
  • Use a CSRF token in the form if the site allows public submissions.
  • For better UX, let users Edit so the form is pre-filled from the session.
    This approach is durable and addresses back-button/duplicate-submit problems while keeping the confirmation page readable and safe.

Recommended Answers

All 2 Replies

I assume that you working on php

If you want to put confirmation page in between, and on confirmation, send it to real handler page.

YOu can echo output using post array

<?php
echo "Name: " . $_POST['name']."<br>";
echo "Address: " . $_POST['address']."<br>";
echo "contact: ". $_POST['contact']."<br>";

?>
<form name=frm id=frm action='handler.php' method ='post'>
<input type=hidden name='name' value ='<?php echo $_POST['name']?>'>
<input type=hidden name='address' value ='<?php echo $_POST['address']?>'>
<input type=hidden name='contact' value ='<?php echo $_POST['contact']?>'>
<input type=submit name='Submit' value ='Confirm'>
</form>
Member Avatar for Member #5881

thank you for your reply.
I don't know how to implement this just yet, but I am working on it.
I can't believe this is eluding me right now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.