I have two PHP files.

The first is called "file1.php":

```
<form action="file2.php" method="get">
<input type="hidden" name="price" value="50">
<input type="hidden" name="id" value="1">
<input type="submit" border="0" name="submit" value="Buy Now">
</form>

```

---

The second is called "file2.php":

```
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" id="id" name="id" value="<?php echo $_GET["id"]; ?>" alt="<?php echo $_GET["price"]; ?>" readonly="readonly" />
</form>

```

---

Now here's my issue:

Some people may look at the source of the page on file1.php and try visiting file2.php. I would want them to be automatically redirected the file1.php or not be able to see file2.php UNLESS they have clicked the submit button from file1.php.

Also some people might try erasing the data was sent from the GET method from the previous page (file1.php), to be able to view file2.php, is there a way to block this from happening? I wouldn't want it to show a 404 error, but simply redirect the person to the file1.php page unless they click on one of the submit buttons from file1.php as there are many forms.

---

I believe this might have something to do with PHP require to be placed on file2.php, but not quite sure how to get it working properly.

Any ideas?

---

*EDIT* (below)
--------------

Thank you everyone so far for all your help and advice.

Alright, so everything seems to be working now using the form method POST. However, to get this working, we must list all variables for each template. Each template has 4 variables. 2 IDs and 2 prices. In example:

```
$T900_0001_R_ID = "#900-0001 - Regular"; 
$T900_0001_R = 75; 
$T900_0001_E_ID = "#900-0001 - Exclusive"; 
$T900_0001_E = 500; 

```

---

Now, my next question is: how do we convert this code to be used into a MySQL database instead, as there will be hundreds, and maybe thousands of templates to sold within just the next few weeks?

---

See the updated files that are working (without MySQL):
-------------------------------------------------------

file1.php:

```
<?php
$T900_0001_R_ID = "#900-0001 - Regular"; 
$T900_0001_R = 75; 
$T900_0001_E_ID = "#900-0001 - Exclusive"; 
$T900_0001_E = 500; 

echo "<form action='test2.php' method='post'><input type='hidden' name='template_price' value='" . $T900_0001_R . "'><input type='hidden' name='template_id' value='" . $T900_0001_R_ID . "'><input type='submit' class='buynow' border='0' name='submit' value='Buy Regular'></form>";
?>

```

file2.php:

```
<?php
$T900_0001_R_ID = "#900-0001 - Regular"; 
$T900_0001_R = 75; 
$T900_0001_E_ID = "#900-0001 - Exclusive"; 
$T900_0001_E = 500; 

echo "<form><input type='text' id='template_id' name='template_id' value='" . $_POST["template_id"] . "' alt='" . $_POST["template_price"] . "' readonly='readonly' class='input-text sum' /></form>";
?>

```