I am working on a program that creates a lease. The user enters data such as tenant name, address, etc into a form. This form is located on a page named leaseCreation.php
. When the form is submitted, the form action is another page named leaseProcessing.php
. This page stores the form values in a MySQL
database and creates a Word document based on the values. (lease).
Everything was working as intended, but I wanted to use a redirect on leaseProcessing.php
to avoid the user refreshing the page and submitting the form data a second time. So, I created another page named leaseProcessed.php
and added the following redirect at the bottom of leaseProcessing.php
where $outputFilename
is the name of the word document.
header("Location: leaseProcessed.php?outputfile=".$outputFilename);
Here is the code from leaseProcessed.php
<?php
session_start();
if(!isset($_SESSION['auth']) || $_SESSION['auth'] != "1"){
header( 'Location: login.php' ) ;
}
if(!isset($_GET)){
header( 'Location: leaseCreation.php' ) ;
}else{
$outputFileName = $_GET['outputfile'];
}
?>
<html>
<head>
<title>Lease Processed</title>
<link rel="stylesheet" type="text/css" href="style\style.css">
</head>
<body>
<?php echo('<a href="'.$outputFileName.'">Download your lease here.</a>');
header("Location: ".$outputFileName);
?>
</body>
</html>
PROBLEM: When the user submits the form on leaseCreation.php
, the url never changes. It remains leaseCreation.php
and I continue to see the form on leaseCreation.php
even though the code on leaseProcessing.php
is executing (Mysql
database is updated and word file is created), and the Word file is opening. I am unsure why the browser url has not updated to leaseProcessed.php
? Clearly code from that page is being executed.
Thanks in advance for any insight!
-Brent