I apologize for the confusion earlier. To achieve the desired functionality, you can follow these steps:
1. In form.php, modify the form's action attribute to point to viewform.php. This will ensure that the form data is sent to viewform.php for processing. Also, include hidden input fields to store the form data, which will be passed to viewdetail.php. Here's an example:
form.php:
HTML:
<form method="POST" action="viewform.php">
<!-- Input fields for user data -->
<input type="text" name="input1" placeholder="Enter Input 1" required>
<input type="text" name="input2" placeholder="Enter Input 2" required>
<!-- Add more input fields here if needed -->
<!-- Hidden input fields to pass form data to viewdetail.php -->
<input type="hidden" name="input1_hidden">
<input type="hidden" name="input2_hidden">
<!-- Submit button -->
<button type="submit">Submit</button>
</form>
2. In viewform.php, retrieve the form data submitted by the user and store it in variables. Then, redirect to viewdetail.php using the header() function, passing the form data as query parameters in the URL. Here's an example:
viewform.php:
PHP:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve the form data
$input1 = $_POST['input1'];
$input2 = $_POST['input2'];
// Store the form data in hidden input fields
echo "<input type='hidden' name='input1_hidden' value='$input1'>";
echo "<input type='hidden' name='input2_hidden' value='$input2'>";
// Redirect to viewdetail.php with query parameters
header("Location: viewdetail.php?input1=" . urlencode($input1) . "&input2=" . urlencode($input2));
exit;
}
?>
3. In viewdetail.php, retrieve the query parameters to get the submitted data. Here's an example:
viewdetail.php:
PHP:
<?php
// Retrieve the query parameters
$input1 = $_GET['input1'];
$input2 = $_GET['input2'];
// Display the submitted data
echo "Input 1: " . $input1 . "<br>";
echo "Input 2: " . $input2 . "<br>";
?>
Now, when the user submits the form in form.php, the data will be passed to viewform.php, stored in hidden input fields, and then redirected to viewdetail.php. In viewdetail.php, the submitted data will be retrieved from the query parameters and displayed.
Please note that it's important to validate and sanitize the input data to ensure it's safe to use in your application.
I apologize for any confusion caused earlier. Let me know if you have any further questions!